javascript - Get element with computed style -
i have couple of elements position: fixed in page. how perform loop through these elements?
something like:
$('body').find([all elements position == fixed]);
you can use filter:
$('*').filter(function() { return $(this).css("position") === 'fixed'; }); the function go through each element , checks condition satisfied. if fixed, returns true. filter() function add-on $() selector select elements satisfy condition.
if above doesn't work, can use this:
$('*').filter(function () { return this.style && this.style.position === 'fixed' }); reason above code:
the .css() jquery's function, works on jquery object. creating jquery object native object, , running jquery function on jquery object can time consuming , performance intensive native functions.
Comments
Post a Comment