Jquery: How to check if the element has certain css class/style
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.
if($('#someElement').hasClass('test')) {
... do something ...
}
else {
... do something else ...
}
if ($("element class or id name").css("property") == "value") {
your code....
}