Ergec Ergec - 9 months ago 52
jQuery Question

.val() doesn't trigger .change() in jquery

I am trying to trigger

on a text box when I change it's value simply with a button but it doesn't work. Check this link. If you type something in textbox then click somewhere else
triggers but if you click only button, it changes textbox value but
doesn't trigger.



onchange only fires when the user types into the input and then the input loses focus.

You can manually call the onchange event using after setting the value:

$("#mytext").change(); // someObject.onchange(); in standard JS

Alternatively, you can trigger the event using: