amy-d
7/25/2016 - 7:15 PM

JS: jQuery Plugin for determining whether a DOM item comes before or after

JS: jQuery Plugin for determining whether a DOM item comes before or after

// REFERENCE: http://stackoverflow.com/questions/7208624/check-if-element-is-before-or-after-another-element-in-jquery
(function($) {
    $.fn.isAfter = function(sel){
        return this.prevAll().filter(sel).length !== 0;
    };

    $.fn.isBefore= function(sel){
        return this.nextAll().filter(sel).length !== 0;
    };
})(jQuery);