I have one select control. I try to update this control with jquery but the value after space omitting.
if (brandObj != "") {
brandObj = eval("(" + brandObj + ")");
$.each(brandObj, function(i, item) {
$("#<%=listBrand.ClientID%>").append( "<option value="+ item.Brand + ">" + item.Brand + "</option>");
});
}
The data which I get from server
But after it render as HTML select , it omit the word after space.whole value is there but once I get the value , it have only half(the value which in double quote). I tried to add
but it is showing as it is. it is not rendering as space. please give your suggession.
You should wrap value of attribute value in quote(Quote It). If you do not wrap them in quote then value after space will be considered as attribute itself:
$("#<%=listBrand.ClientID%>").append("<option value='"+ item.Brand + "'>" + item.Brand + "</option>");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With