Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error appending to <select> element in Internet Explorer 8

I can not seem to append items to a <select> element in Internet Explorer 8. Here is the code, it works perfectly in Chrome and internet explorer 9, is there another way I should do it so that it works in Internet Explorer 8?

$("#" + data[0].Name).append($('<option/>', {
    value: data[i].Values[k].Value,
    text: data[i].Values[k].Label
}));
like image 628
Captain0 Avatar asked Nov 26 '25 15:11

Captain0


1 Answers

Here is the working solution. http://jsfiddle.net/8yFsh/

It worked for me in IE8. below is the code to add option

$('#ptest'). 
      append($("<option></option>"). 
      attr("value","pavan"). 
      text("pavan"));  
like image 150
Pavan Avatar answered Nov 29 '25 03:11

Pavan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!