#3041 closed bug (wontfix)
appendTo does not add option text to select box in IE
Reported by: | pbcomm | Owned by: | |
---|---|---|---|
Priority: | minor | Milestone: | 1.3 |
Component: | core | Version: | 1.2.6 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
<select id="choose"></select> var option = document.createElement('option'); option.text = 'text'; option.value = 'value'; jQuery(option).appendTo('#choose');
The code above adds the options but does not display the text in the select box in IE.
Attachments (1)
Change History (7)
comment:1 Changed 15 years ago by
comment:3 Changed 15 years ago by
I meant about your first comment
This is due to: IE and Opera are missing .innerHTML support for TABLE-related and SELECT elements and should be considered major.
Do you mean this is a browser bug ? or jQuery's ? could you add more detail and if possible, some links ?
comment:4 Changed 15 years ago by
http://support.microsoft.com/kb/276228
however one thing I noticed was
This does not work in IE6/IE7
var option = document.createElement('option'); option.text = 'test'; option.value = 'test'; jQuery(option).appendTo('#choose');
this one does work in IE6/IE7 and Firefox (just changing the order
var option = document.createElement('option'); jQuery(option).appendTo('#choose'); option.text = 'test'; option.value = 'test';
comment:6 Changed 15 years ago by
Resolution: | → wontfix |
---|---|
Status: | new → closed |
Replying to pbcomm:
Flesler, This is a jQuery bug.
You need to justify statements like this one. I tried this without jQuery, just plain Javascript and it still fails.
This is an odd IE bug. To work around you just need to set the 'text' after appending it, or use:
option.appendChild(document.createTextNode('test'));
That is actually the consistent way of doing this for any node. If you use jQuery:
$('#choose').append('<option value="test">test</option>'); // or $('<option />').val('test').text('test').appendTo('#choose');
You shouldn't get any trouble as the attribute 'text' is never used.
I'll close this as there's no sense in catching this in my opinion as you have a ton of workarounds.
This is due to: IE and Opera are missing .innerHTML support for TABLE-related and SELECT elements and should be considered major.