Ergec Ergec - 1 year ago 149
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.


Answer Source

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:

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download