This is related to Adding options to a <select> using jQuery? but has a different focus
My problem is that I am not able to append option-elements to a select in IE8. When changing the engine to IE7 in IE's developer-tools it does work.
It also works in FF and Chrome.
var valT = "some Text";
var charsToIgnore = 2;
var o = new Option(valT.slice(charsToIgnore), valT);
$(o).html(valT.slice(charsToIgnore));
$('#availablePages').append(o);
another method I tried:
$('<option/>', {value: valT, text: valT}).appendTo("#availablePages");
availablePages is the id of my select. The select does not contain any elements when the page is received by the client. My doctype is <!DOCTYPE html>.
I also tried to remove all other scripts and css from my site to make sure no side-effects apply.
Edit:\ Thanks for downvoting! It's not my fault if provided solutions do not work in all IE8-versions. Since my question was What DOES work in all IE8-versions? it is, from my point of view, understandable that I do not accept answers which do not work for me. As you can see in Adding options to a <select> using jQuery? I am not the only one for whom the other replies here do not work. Using the Up-/Down-Vote functionalities as channel for your own mood is no good Wiki/QA-behaviour.