Is there a way to programmatically trigger to .change event with jQuery/javascript?
I want a piece of code that will fire a DOM change
event for a select/option box such as the following:
<div data-role='fieldcontain' class='none'>
<select name='ACTC' class='none cl_preAction' >
<option data-location='S' value='001'>Fire</option>
<option data-location='T' value='002'>Flood</option>
<option data-location='T' value='003'>End Of World</option>
</select>
</div>
Just call change().
$(".cl_preAction").change();
Bind an event handler to the "change" JavaScript event, or trigger that event on an element.
You can trigger an event using the trigger function of jQuery.
$(".none select").trigger('change');
"Although .trigger() simulates an event activation, complete with a synthesized event object, it does not perfectly replicate a naturally-occurring event."
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With