Why does the jquery change event not trigger when I set the value of a select using val()? Why does the jquery change event not trigger when I set the value of a select using val()? jquery jquery

Why does the jquery change event not trigger when I set the value of a select using val()?


Because the change event requires an actual browser event initiated by the user instead of via javascript code.

Do this instead:

$("#single").val("Single2").trigger('change');

or

$("#single").val("Single2").change();


I believe you can manually trigger the change event with trigger():

$("#single").val("Single2").trigger('change');

Though why it doesn't fire automatically, I have no idea.


Adding this piece of code after the val() seems to work:

$(":input#single").trigger('change');