Created
July 25, 2016 19:15
-
-
Save ahaywood/b0f78cdbebeb1b278b4da6a60eac3e87 to your computer and use it in GitHub Desktop.
JS: jQuery Plugin for determining whether a DOM item comes before or after
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment