On Mar 19, 5:00 pm, bob <xoxeo...@gmail.com> wrote:
> Well, that did not help much
> So what is the problem then?  Why do I get false?

Internally, a jQuery object is an array of references to DOM objects.
Even though two jQuery objects may contain the same references
internally, they are distinct objects, and therefore not ==.

> How do I get true value?

Something like this:

$.fn.equals = function(compareTo) {
        if (!compareTo || !compareTo.length || this.length!=compareTo.length)
{
                return false;
        }
        for (var i=0; i<this.length; i++) {
                if (this[i]!==compareTo[i]) {
                        return false;
                }
        }
        return true;
}

$('#home').equals( $('#home') ); // True!

Matt Kruse

Reply via email to