Every time you call $(...)
jQuery will create a new object. Because of this, comparing two jQuery collections with ==
will never return true, even when they are wrapping the same native DOM elements:
$('body') == $('body') // false
In order to test if two jQuery objects refer to the same native DOM elements, use is
:
var $a = $('body');
var $b = $('body');
$a.is($b); // true
Jasmine equality matcher for jQuery
See here for a custom Jasmine matcher that tests if two jQuery objects are equal.
Posted by Henning Koch to makandra dev (2012-12-27 18:49)