Created
February 3, 2015 20:55
-
-
Save marcus-at-localhost/5ba412d225045fbb082a to your computer and use it in GitHub Desktop.
jquery select by position
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
// http://stackoverflow.com/a/9769532/814031 | |
$('*').filter(function(){ | |
var position = $(this).css('position'); | |
return position === 'absolute'; | |
}); | |
// or extend jquery selector engine | |
// http://stackoverflow.com/a/9770766/814031 | |
$.extend($.expr[':'],{ | |
absolute: function(el) { | |
return $(el).css('position') === 'absolute'; | |
}, | |
relative: function (el) { | |
return $(el).css('position') === 'relative'; | |
}, | |
static: function (el) { | |
return $(el).css('position') === 'static'; | |
}, | |
fixed: function (el) { | |
return $(el).css('position') === 'fixed'; | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment