Search code examples
javascripthtmldom-eventsonchange

Will I trigger a change event if I use Javascript to set a <option> as selected?


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?


Solution

  • 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();