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);