Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Onchange input event isn't fired on jquery

I'm working with jquery.

And i have text input in a form, i would like to process the change event.

$("#my_input").change(function(){alert('123');});

the event is fired normally when i edit the field manually, but when i change the field's value with a script (sometimes with an external script) it doesn't work.

is there any solution ?

and thanks in advance.

like image 700
Youcef04 Avatar asked Mar 21 '12 13:03

Youcef04


1 Answers

The change event is not designed to detect programmatic changes. You can trigger the event manually when setting the value, though:

$('#my_input').trigger('change');

shortcut:

$('#my_input').change();
like image 104
jwueller Avatar answered Sep 30 '22 17:09

jwueller