I've observed that, in Google Chrome, setting an <option>
as selected via Javascript does not trigger the respective <select>
tag's change event.
Can I count on this behavior holding true in all other modern browsers?
I've observed that, in Google Chrome, setting an <option>
as selected via Javascript does not trigger the respective <select>
tag's change event.
Can I count on this behavior holding true in all other modern browsers?
Yes, that should hold true. In my experience this works in IE 6 up, Chrome, FF and Safari. I would agree that testing in all browsers you intend supporting is sensible though !
Setting any value for any field in JavaScript should not trigger any events.
If they did you would end up in an endless loop of events firing.
If you want, you can "call" the change event manually.
option:selected yes it works I just used it myself. Even held true in IE 6 - IE 8 webkit and FF
Setting an option as selected via JavaScript or selecting an option by focusing then using up and down buttons to select, is not accepted as an event by the onchange()
event handler as evident by the following links :
PS : A similar situation occurred when i tried to evoke <element onmousedown="doStuff();">
by calling element.click();