I have a tag such as:
<div class="menu" style="display:relative;">
..and I am trying to check with:
if ($('.menu').css('display','relative'))
.. the CSS for .menu has display:fixed; so it's ignoring the inline style and returning negative for if.
What's the best way to check the active style attribute on an element regardless if in CSS or inline?
Thanks.
With your code you are setting display attribute with relative.
try this:
if ($('.menu').css('display') == 'relative'){
//your code
}
The problem is that display hasn't attribute relative, maybe you mean position like this:
<div class="menu" style="position:relative;">
and jQuery:
if ($('.menu').css('position') == 'relative'){
//your code
}
There is no display:relative in CSS. it is position:relative
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With