Given that I have a document similar to this:
<div>
<div data-myAttr = "foo"></div>
<div data-myAttr = "bar"></div>
</div>
<div>
<div data-myAttr = "foo"></div>
<div data-myAttr = "bar"></div>
</div>
How can I get all elements that contain data-myAttr with foo's and bar's grouped?
Edit: this is more of a theoretical question. I have no tried code that has failed but am exploring a more elegant option for code that already exists.
BTW, thank you for the -1!?
Edit: can someone mark this as duplicate? Found applicable answer here: Group and count HTML elements by data attribute in jQuery