Is there anyway to have a conditional jquery event?
i.e.
if thisBox.is(clicked) or thatBox.is(clicked) {
//do this
}
My example pertains to this piece of code:
$('.pdfClose').click(function(){
$('.thePDF').fadeOut("slow", function(){
$('.pdfContainer').removeClass('pdfShown');
});
});
So what I would like to have is
($('.pdfClose') || $('.pdfContainer')).click(function(){
$('.thePDF').fadeOut("slow", function(){
//$(this).hide();
$('.pdfContainer').removeClass('pdfShown');
});
});
Something like that, but I don't even know if it exists or what the proper syntax is.
Any help is greatly appreciated!
Like this
$('.pdfClose, .pdfContainer').on('click', function(){
var self = this;
$('.thePDF').fadeOut("slow", function(){
$(self).removeClass('pdfShown');
});
});
you can use multiple selectors by separating them with a comma, and inside the event handler this would reference the current one.
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