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.