The logic in the change()
event handler is not being run when the value is set by val()
, but it does run when user selects a value with their mouse
If you've just added the select option to a form and you wish to trigger the change event, I've found a setTimeout is required otherwise jQuery doesn't pick up the newly added select box:
window.setTimeout(function() { jQuery('.languagedisplay').change();}, 1);
Adding this piece of code after the val() seems to work:
$(":input#single").trigger('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.