The followingcode will fire alert to the click event for elements with Class = a.cssPauseAll
OR
attribute = historyID
$(document).on("click","a.cssPauseAll,[historyID]", function () {
alert($(this));
});
How can I use multiple selectors using an AND
operator?
which means, the elements with the a.cssPauseAll
class AND
historyID
attribute?
Just remove the ,
from your selector:
$(document).on("click","a.cssPauseAll[historyID]", function () {
historyID
is not a valid attribute you can use data-*
attribute instead:
$(document).on("click","a.cssPauseAll[data-historyid]", function () {
the elements with the a.cssPauseAll class AND historyID attribute
Use the following selector:
a.cssPauseAll[historyID]
Test it yourself - http://jsfiddle.net/SrNDt/
Note: Commas separate selectors and therefore behave as a logical OR
. Chaining expressions into a single selector behave as a logical AND
.
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