Originally Posted by VIPStephan
Well, lacking a satisfying solution I ended up putting the option into the HTML rather than adding it with JS. Apparently there is no way to check for the attribute, not for the state. Thanks for your thoughts, though.
you should be able to check the <select>'s selectedIndex instead of checking each option. you only need to check each option when the attrib "multiple
" is used on the <select>.
also note that you can use option.getAttribute
("selected") or even hasAttribute
instead of option.selected
to differentiate between the state and the attribs. Normally however, state and attribs are synced; but NOT ALWAYS!
finally, i think option.selected
should be set to true, not sure how every browser handles a string setting...
BROWSER STATS [% share]
(2013/10/31) IE7:0.5, IE8:8.6, IE9:5.3, IE10:12.3, FF:17.7, CH:41.8, SF:8.1, MOBILE:20.4