Hi! I have a div:
<div style="test" id="someElement"></div>
Is there any way to check if the certain element:
$("#someElement")
has a particular css style (in my case, "test").
Thank you very much!
Hi! I have a div:
<div style="test" id="someElement"></div>
Is there any way to check if the certain element:
$("#someElement")
has a particular css style (in my case, "test").
Thank you very much!
if($('#someElement').hasClass('test')) {
... do something ...
}
else {
... do something else ...
}
i've found one solution:
$("#someElement")[0].className.match("test")
but somehow i believe that there's a better way!
CSS Styles are key-value pairs, not just "tags". By default, each element has a full set of CSS styles assigned to it, most of them is implicitly using the browser defaults and some of them is explicitly redefined in CSS stylesheets.
To get the value assigned to a particular CSS entry of an element and compare it:
if ($('#yourElement').css('position') == 'absolute')
{
// true
}
If you didn't redefine the style, you will get the browser default for that particular element.