Home    Articles

 

Jquery: how to verify if two elements are the same

 

You should use .is() function like this:

    $(document).click(function(e) {
        if($('div.class-name').is(e.target)) {
             console.log("It's the same div.");
        } else {
            console.log('Not the same div.')
        }
    });

That should be all. From here you can customize.

by