I have a button and a select in my form. The button has onclick event while the select has onchange event. How to make the select has both onclick and onchange event?
This is the script:
$('#i_btn').on('click', function(){
alert('Event 1');
});
$('#i_sel').on('change', function(){
alert('Event 2');
});
When the select is changed, it should do alert('Event 1'); alert('Event 2');. I do not want to rewrite the onclick code in onchange
Write your events as separate functions :
$('#i_btn').on('click', event1);
$('#i_sel')
.on('change', event1)
.on('change', event2);
function event1(){
alert('Event 1');
}
function event2(){
alert('Event 2');
}
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