Captain0
Captain0

Reputation: 2623

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
}));

Upvotes: 3

Views: 2704

Answers (1)

Pavan
Pavan

Reputation: 4329

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"));  

Upvotes: 2

Related Questions