Test for equality (.equals)
It would be nice to have a function to test for JQuery equality.
I've made a .equals function which does the equality checks just like
many other languages:
/**
* Returns true when the two jQuery objects have the same objects
selected
* in the same order, false otherwise.
*/
$.fn.equals = function(other) {
if (this.length!=other.length) {
return false;
}
var result = true;
this.each(function(i){
if (this!=other[i]) {
result = false;
// break each loop
return false;
}
});
return result;
};
Maybe this could make it to the JQuery core someday?
grtz,
Rick