Skip to content

Instantly share code, notes, and snippets.

@ahaywood
Created July 25, 2016 19:15
Show Gist options
  • Save ahaywood/b0f78cdbebeb1b278b4da6a60eac3e87 to your computer and use it in GitHub Desktop.
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
// 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