jQuery check if element has a specific style property defined inline

后端 未结 5 1783
隐瞒了意图╮
隐瞒了意图╮ 2020-11-30 07:19

I need to check whether an element has a defined css property given to it, but I\'m having some trouble using the jQuery.css() function.

The property I\'m looking fo

5条回答
  •  感情败类
    2020-11-30 07:49

    Use .attr to check the style attribute.

    if(base.$element.attr('style').length > 0) {
       //...
    }
    

    If you care about the width, then

    if(base.$element.attr('style').indexOf('width') !== -1) {
       //...
    }
    

提交回复
热议问题