find elements with position:attribute

前端 未结 3 1095
无人共我
无人共我 2020-12-31 08:35

I would try to find all \"absolute\" elements in my page; with jQuery I though it would be something like

$(\'[position=\"absolute\"]\')

bu

3条回答
  •  不知归路
    2020-12-31 09:21

    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

     

    but in your case position is a css property

提交回复
热议问题