Get all elements with `position:fixed` in an HTML page?

前端 未结 4 1106
梦毁少年i
梦毁少年i 2021-01-05 03:07

Reason for doing that: I\'m debugging css of my webpage.. some elements appeared and they\'re not supposed to appear. I suspect it is the issue with element positioning.. th

4条回答
  •  醉酒成梦
    2021-01-05 03:25

    This one is using jQuery. I hope you are find with it.

     var find = $('*').filter(function () { 
            return $(this).css('position') == 'fixed';
        });
    

    I think this one works using a pure javascript:

    var elems = document.body.getElementsByTagName("*");
    var len = elems.length
    
    for (var i=0;i

提交回复
热议问题