Performing the following comparison using the jQuery "is" function will return false since the DOM elements are not exactly the same, although visually and functionally they are the same:
var $a = $('<div id="test" href="http://www.google.com"></div>');
var $b = $('<div href="http://www.google.com" id="test"></div>');
$a.is($b);
Using direct comparison of DOM objects will also return false.
See an example run: http://jsfiddle.net/6zqwn/5/
So, is there a way to avoid taking attribute order into account when comparing?
(Why I ask this question: I use these comparisons in cross-browser unit tests, in which different browsers reorder the attributes, while still functionally creating the same DOM elements.)
Yosi source
share