JSFiddle - React, Tailwind, and code Playground

by gabrieleromanato

HTML

<div><a href="#" id="run">Compare</a></p>

<div class="test">Test</div>

<p id="test">Test</p>
    
<div id="results"></div>

CSS

#results {
    font-family: monospace;
}

JavaScript

(function($) {

    $.fn.isEqual = function($otherSet) {
        if (this === $otherSet) {
            return true;
        }
        if (this.length != $otherSet.length) {
            return false;
        }
        var ret = true;
        this.each(function(idx) {
            if (this !== $otherSet[idx]) {
                ret = false;
                return false;
            }
        });
        return ret;
    };

})(jQuery);



$('#run').click(function() {

    var $test1 = $('div.test').eq(0);
    var $test2 = $('#test');

    var test1 = ($test1.isEqual($test1)) ? ' is equal to ' : ' is not equal to ';
    var test2 = ($test1.isEqual($test2)) ? ' is equal to ' : ' is not equal to ';

    $('#results').html('div.test ' + test1 + 'div.test' + '<br/>' + 'div.test' + test2 + 'p#test');


    return false;

});