I would try to find all \"absolute\" elements in my page; with jQuery I though it would be something like
$(\'[position=\"absolute\"]\')
bu
Building on Nicola's answer, you can also extend jQuery's selector engine.
$.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';
}
});
Then you can you do things like this.
$(':absolute');
$('div.sidebar:relative');
You could use filter()
$('*').filter(function(){
var position = $(this).css('position');
return position === 'absolute';
});
You can't use attribute equals selector because because that selector would search elements with an attribute called position that equals absolute like this
<div position="absolute">
but in your case position is a css property
Try this:
$("*[style*='position:absolute']").each (function () {
alert($(this).html());
});
Demo : http://jsfiddle.net/XRRbr/1/
More info: http://api.jquery.com/attribute-contains-selector/