0

For example given two divs like this:

.example{
  width: 200px;
  height: 200px;
  z-index: 4;
}
<div id="first" style="height:100px;width:200px;z-index:5;">Hardcoded</div>
<div id="second" class="example" >Css</div>

How can i detect by jquery/javascript if, for example, the height of the div is set by style attribute? Or how can i detect by jquery/javascript if the height is set but not by a css class?

It seems there is a bunch of misunderstand what i'm really asking, altough one answer was pretty close but deleted: The question is not "which value is set for the height". or "does the div has a specific class set" Given a specific style property like 'height'. I want to know two things:

  1. Is the height set in any non-browser-default way like by a css class or style? (i think i can get by myself)
  2. If yes, is the height set by the style="...." attribute or by a class=""? Which class doesnt matter.
pnuts
  • 58,317
  • 11
  • 87
  • 139
John Doe
  • 2,746
  • 2
  • 35
  • 50

1 Answers1

1

You can use jQuery as follows

<script>  
$(document).ready(function() {  
    if($('#first').attr("style").indexOf("height") != -1) {
        alert("height is hardcoded");
     }
    else {
        alert("height is not hardcoded");  
     }

  });
</script>
captainsac
  • 2,484
  • 3
  • 27
  • 48