How do you select elements based on their style?

后端 未结 3 1714
清歌不尽
清歌不尽 2020-11-30 04:19

Using jQuery, how would you find elements which have a particular style (eg: float: left), regardless of whether it\'s an inline style or one defined in a CSS f

3条回答
  •  鱼传尺愫
    2020-11-30 04:50

    This is gonna be slow. Like REALLY slow. If you know you need to select all elements with a given CSS style, you will see much better performance by applying a single additional css rule to each element, and then selecting by that rule.

    It's going to be MUCH faster and more readable to boot.

    CSS:

    .float-left {float:left}
    

    Javascript:

    $('.float-left');
    

提交回复
热议问题