How to preserve internal symbols when assigning new values to html fields?


financial doctor

We have a dropdown field that will display the user's alias. To emphasize that it is a drop-down list, there is a class called caretdisclosure triangle.

This part of the code is written in html like this.

<a
  id="username"
  href="#"
  class="dropdown-toggle"
  data-toggle="dropdown"
  role="button"
  aria-haspopup="true"
  aria-expanded="false"
>**username will go here**<i id="caret" class="caret"></i>
</a> 

When we assign value to "username", the caret disappears. I think it's because <i id="caret" class="caret"></i>within that class.

So what I thought to fix this is to add the class to the string when reassigning

$('#username').text(name);
$('#username').addClass("caret")

Obviously this is not the right way, otherwise I wouldn't be asking the question. How can I prevent the triangle from disappearing when filling the field?

I also moved the class outside, id=usernamewhich messed up how the page was displayed.

Arslan 2012
<a
  href="#"
  class="dropdown-toggle"
  data-toggle="dropdown"
  role="button"
  aria-haspopup="true"
  aria-expanded="false"
><span id="username">**username will go here**</span><i id="caret" class="caret"></i>
</a> 


$('#username').text(name);

Related


How to put constant symbols in html fields

Ayesh I have an html input field <input name="expiry" type="text" placeholder="MM/YY"/> I need to enter a "/" so that if the user enters the value "06", the value should be after the "/" like "06/" and then when he enters the year "13", the value should autom

How to add allowed symbols on input fields in HTML?

canoe I have my own create inputtab and have to fill in the phone number: <base-input style="margin-bottom: 15px; width: 100%; max-width: 510px;" v-model="phone" type="tel" placeholder="Mobile phone" /> How to add only

How to put constant symbols in html fields

Ayesh I have an html input field <input name="expiry" type="text" placeholder="MM/YY"/> I need to enter a "/" so that if the user enters the value "06", the value should be after the "/" like "06/" and then when he enters the year "13", the value should autom

How to preserve html form values with Flask?

8oh8 I am using Flask and connecting. How do I save the form data when the user returns to the same view after submitting the form? I think I could use WTForms to do this in the past, but is there another way? WTForms seems to be just a form of contact. I've t

How to preserve html form values with Flask?

8oh8 I am using Flask and connecting. How do I save the form data when the user returns to the same view after submitting the form? I think I could use WTForms to do this in the past, but is there another way? WTForms seems to be just a form of contact. I've t

How to preserve html tags when parsing xml?

user_78361084 I try to parse the following xml. My playground can be found here package main import "fmt" import "encoding/xml" type ResultSlice struct { MyText []Result `xml:"results>result"` } type Result struct { MyResult string `xml:"text"` } fu

How to preserve html tags when parsing xml?

user_78361084 I try to parse the following xml. My playground can be found here package main import "fmt" import "encoding/xml" type ResultSlice struct { MyText []Result `xml:"results>result"` } type Result struct { MyResult string `xml:"text"` } fu

How to preserve html tags when parsing xml?

user_78361084: I try to parse the following xml. My playground can be found here package main import "fmt" import "encoding/xml" type ResultSlice struct { MyText []Result `xml:"results>result"` } type Result struct { MyResult string `xml:"text"` } f

Preserve constructor when annotating fields

Nason: I have the following class. public class StatusCategory { @JsonProperty("key") private final String m_key = null; public String getKey() { return(m_key); } } What -keepoptions are there to ensure that Proguard doesn't delete the c

Preserve constructor when annotating fields

Nason I have the following class. public class StatusCategory { @JsonProperty("key") private final String m_key = null; public String getKey() { return(m_key); } } What -keepoptions are there to ensure that Proguard doesn't delete the co

Preserve constructor when annotating fields

Nason I have the following class. public class StatusCategory { @JsonProperty("key") private final String m_key = null; public String getKey() { return(m_key); } } What -keepoptions are there to ensure that Proguard doesn't delete the co

Preserve constructor when annotating fields

Nason: I have the following class. public class StatusCategory { @JsonProperty("key") private final String m_key = null; public String getKey() { return(m_key); } } What -keepoptions are there to ensure that Proguard doesn't delete the c