This question and this question explain how to compare the contents of two jQuery elements/objects?
However, we need to compare the contents as well as their attributes.
Element 1:
<div id="A" width="200" height="200" style="stuff"></div>
Element 2:
<div id="B" width="300" height="300" style="differentstuff"></div>
Element 3:
<div id="C" width="200" height="200" style="stuff"></div>
Assume all three elements have the same content as tested by the $.html()
method described in the linked answers.
Elements 1 and 3 should match as equal while element 2 should not be equal to elements 1 and 3.
Is there a native way to do this, or do you have to manually check each attribute? Ideally, there would be a way to get the "attribute content" of an element as way for comparison.