JQuery: check if element is in normal flow

前端 未结 3 765
傲寒
傲寒 2021-02-07 05:05

What is the most elegant way to check whether an element is in the normal flow using jQuery?

According to the CSS3 specification,

A box belongs t

3条回答
  •  花落未央
    2021-02-07 05:35

    Instead of looking at it retroactively, you could pre-empt the need for this by using data annotations. Any time you create or define an element, set its attribute data-flow to true or false.

    For example:

    var newDiv = document.createElement("div");
    newDiv.style.position = "absolute";
    newDiv.setAttribute("data-flow","false");
    

    Or in html

    And then you could simply select these elements with a selector:

    $('*[data-flow=false]')
    

提交回复
热议问题