Skip to content

Instantly share code, notes, and snippets.

@nextend
nextend / isBefore.js
Created May 15, 2017 14:12 — forked from xilin/isBefore.js
Compare DOM tree order of elements
// http://stackoverflow.com/questions/3860351/relative-position-in-dom-of-elements-in-jquery
// What this does is .add() the additional element (or selector)
// (which jQuery keeps in document order) and then checks if it's the second of the two.
(function($) {
$.fn.isBefore = function(elem) {
if(typeof(elem) == "string") elem = $(elem);
return this.add(elem).index(elem) > 0;
}
})(jQuery)
@nextend
nextend / gist:7986647
Last active December 31, 2015 12:29 — forked from alexindigo/gist:1871785
Internet explorer 11 support added
// {{{ win-safari hacks, scratch this,
// let's just expose platform/browser to css
(function()
{
var uaMatch = '', prefix = '';
if (navigator.userAgent.match(/Windows/))
{
$('html').addClass('x-win');
}