If I have a table which has 4000 rows
<table>
<tr class="a b c d e f g"><td>xxx</td></tr>
<tr class="a c d e f g"><td>xxx</td></tr>
<tr class="d e f g"><td>xxx</td></tr>
<tr class="a d e f g"><td>xxx</td></tr>
.
.
.
.
.
</table>
If I want to select rows which have classes (a or b or c) and (d or e) and (a or g)
How can I code the selector statement?
Thanks
jQuery - Multiple Elements SelectorYou can specify any number of selectors to combine into a single result.
To select multiple elements of an html page using multiple elements selector, we pass the element names inside parenthesis, in double quotes, separated by commas. For example: $(“div, p, h2”) this will select all the div, p and h2 elements of a page.
Use the querySelectorAll() method to select elements by multiple ids, e.g. document. querySelectorAll('#box1, #box2, #box3') . The method takes a string containing one or more selectors as a parameter and returns a collection of the matching elements.
Try this:
$('.a, .b, .c').filter('.d, .e').filter('.a, .g')
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