Side navigation
#3041 closed bug (wontfix)
Opened June 14, 2008 06:16AM UTC
Closed June 27, 2008 10:44PM UTC
Last modified March 14, 2012 09:30PM UTC
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 (6)
Changed June 16, 2008 03:54PM UTC by comment:1
Changed June 17, 2008 08:41PM UTC by comment:2
Do you have a link that explains what you are saying here ?
Changed June 23, 2008 08:14PM UTC by comment:3
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 ?
Changed June 24, 2008 07:21AM UTC by comment:4
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';
Changed June 24, 2008 02:04PM UTC by comment:5
Flesler,
This is a jQuery bug.
Changed June 27, 2008 10:44PM UTC by comment:6
resolution: | → wontfix |
---|---|
status: | new → closed |
Replying to [comment:5 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.