Triggering event in a Form/Javascript

Sometimes the values you put in the form through any kind of way except user interaction are not triggering change event upon which some other parts of the form behave. In order to forcefully trigger the even, you can use jQuery.
jQuery('YOUR_SELECTOR').trigger('change');
or simply
$('YOUR_SELECTOR').trigger('change');

My Advice. ALWAYS use jQuery rather than any custom made functions, since jQuery is guaranteed to be web browser compatible! And it is cool and easy!

Comments

renesto said…
Additional note: Dont use it too frequently one after each other, as it blocks the web browser.
More convenient way is maybe doing the following. jQuery('*').trigger('event'); (only once)

Popular posts from this blog

Timeline on Latex

Exporting Skype Chat/Skype Contacts to csv file using the shell script and sqlite3 (usually already installed on mac)

trim() not supported by IE7 and IE8