Skip to content

Instantly share code, notes, and snippets.

@marcus-at-localhost
Created February 3, 2015 20:55
Show Gist options
  • Save marcus-at-localhost/5ba412d225045fbb082a to your computer and use it in GitHub Desktop.
Save marcus-at-localhost/5ba412d225045fbb082a to your computer and use it in GitHub Desktop.
jquery select by position
// 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