jQuery: select style attribute?

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

How to select with a specific style attribute?

5条回答
  •  渐次进展
    2021-01-11 16:31

    maybe try

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

    It would be easier however to select the element by one attribute such as id or css class, or by it's position to an element that has an id or css class.

提交回复
热议问题