When handling events with multiple selectors, such as:
$('.item a, .another-item a').click(function(e) {
});
Is it possible to determine which parent selector triggered the event? Was it .item
or .another-item
?
Thank you!
Since a selector can be just about anything, you'd have to check for specific, such as:
if($(this).is('.item a')){
//your code here
} else if ($(this).is('.another-item a')){
//more here
}
You can use jQuery is
.
if($(this).is('.item a')){
// code
}
else if($(this).is('.another-item a')){//remove 'if ' in case there are only two selector separated by commas.
//code..
}
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