When looking to return multiple elements with different data attribute and different data attribute value were both ARE NOT always present
<p class='my-class' data-attribute1='1'></p>
<p class='my-class' data-attribute2='2'></p>
// data-attribute1 OR data-attribute2
$(".my-class").filter(`[data-attribute1="${firstID}"],[data-attribute2="${secondID}"]`);
When looking to return multiple elements with different data attribute and different data attribute value were both ARE always present
<p class='my-class' data-attribute1='1' data-attribute2='1'></p>
<p class='my-class' data-attribute1='1' data-attribute2='2'></p>
// data-attribute1 AND data-attribute2
$(".my-class").filter(`[data-attribute1="${firstID}"][data-attribute2="${secondID}"]`);
The placement of the comma is crucial to differentiate between finding with OR or an AND argument.
It also works for elements who have the same data attribute but with different attribute value
$(".my-class").filter(`[data-attribute1="${firstID}"],[data-attribute1="${secondID}"]`);
I was inspired by this post of @omarjebari on stackoverflow.
.slide-link
with the attribute of[data-slide="0"]
. Since something cannot be a descendant of itself, it doesn't have anything to return. However, if you had a wrapper around these links, then this would have worked:$('.slide-link-wrapper').find('[data-slide="0"]').addClass('active');
– Counterscarp