开发者

jQuery Detect CSS Property Change

开发者 https://www.devze.com 2023-01-04 11:37 出处:网络
开发者_如何学CI am trying to use jQuery to establish whether a CSS property has changed inside a class. I do npt want to use .HasClass() - I want to find a property within the CSS - namely
开发者_如何学C

I am trying to use jQuery to establish whether a CSS property has changed inside a class. I do npt want to use .HasClass() - I want to find a property within the CSS - namely

display:block;

I thought maybe this might work ?

if (jQuery('css-class').css('display') == 'block')

But not sure if it does.


jQuery's .css('css-property') function will return the value of the property, if it exists. So, the check for display:block

if($('selector').css('display') == 'block')

does work.


From what I understand, you should replace css-class with a selector:

if (jQuery('#some_id').css('display') == 'block')
{
  // your code...
}

The code within if block will execute if the element with id #some_id has display set to block.

0

精彩评论

暂无评论...
验证码 换一张
取 消