Question

I wonder whether there is a way to read a special css-value of a class with jQuery. The scenario looks more or less like this:

HTML:

<div class="box"></div>

CSS:

.box { margin-top: 100px; }

Now I would like to check whether that .box has a margin-top of 100px or not to make in if-statement based on it.

Was it helpful?

Solution

The answer is exactly as Jason referred in the his comment. Here is a jsfiddle for your reference

jquery used:

$(function(){
    if($(".box").css('margin-top') == '100px'){
        alert('yes');
    }
});
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top