Reputation: 533
On a certain event, I want to trigger a click event that loads a tab and then trigger another click event on a button on the tab consecutively.
Is it possible to trigger two click events in sequence? When I try doing so, the second one doesn't work.
Upvotes: 0
Views: 1307
Reputation: 40639
Yes
you can by using trigger() like,
$('#button1').click(function() {
$('#tab,#button2').trigger('click');// trigger click of two elements
// $('#tab,#button2').click();// use click() directly
});
Upvotes: 4
Reputation: 2269
$('#button1').click(function() {
// do something here
});
$('#button2').click(function() {
// do something else here
// then simulate clicking the other thing:
$('#button1').click();
});
Upvotes: 2