I need a cross-platform way to insert OPTIONs into a SELECT with jQuery. I think I recall in the past that IE6 does nothing when this is called:
<select id="myselect" size="1">
<option value=""></option>
</select>
<script type="text/javascript">
$('#myselect').append('<option value="test1">test1</option>');
$('#myselect').append('<option value="test2">test2</option>');
</script>
I think I recall that the above worked in all browsers as well as Firefox 2+ and IE7+, but not IE6. Correct? If so, what's the workaround?
First off, you aren't waiting for the DOM to be ready with your code. You should be wrapping your jQuery code in:
I'm not sure about IE6 compatibility, but you could try the .appendTo function instead, such as:
example:
http://jsfiddle.net/W6L9d/
JavaScript is Cross-Platform, Even IE6.
To test how it looks in IE6 open Internet Explorer Browser (exist in Windows 10, it is not Edge Browser) and use F12 keyboard button (Developer tools), and in debug menu choose last button - Emulation - there you can see how it works in IE6, IE7, IE8, IE9, IE10 etc. The full screen example to test IE6 here: http://jsfiddle.net/3Qv6P/embedded/result/
See how dynamically is changing the list of states if I choose the US or Canada
example: http://jsfiddle.net/3Qv6P/
example: http://jsfiddle.net/3Qv6P/