jQuery Detect CSS Property Change
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
.
精彩评论