jQuery: select style attribute?

前端 未结 5 882
一生所求
一生所求 2021-01-11 16:04

How to select with a specific style attribute?

5条回答
  •  感动是毒
    2021-01-11 16:44

    To my knowledge, there's no way to do that using a jQuery selector, but you can use the filter() method instead:

    $("div").filter(function() {
        var $this = $(this);
        return $this.css("width") == "420px"
            && $this.css("text-align") == "left"
            && $this.css("margin-top") == "10px"
            && $this.css("margin-bottom") == "10px";
    });
    

提交回复
热议问题