Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6201197
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T04:30:33+00:00 2026-05-24T04:30:33+00:00

I would like to know using jquery if a div is height constrained or

  • 0

I would like to know using jquery if a div is height constrained or not.

For example this div is constrained to 100px, whatever the size of the content the div will have 100px height:

    <div style="height: 100px;">
         bla bla
    </div> 

and this one is not constrained and will take the height of it’s content :

    <div>
          bla bla
    </div>

in other words I want to know if the height was set (and what if so) either by setting the style attribute or with a separate css style.
Thanks

Solution for FF3.6 FF5 IE8 Chrome12 and Opera11 :

function css(a){
  var sheets = document.styleSheets;
  var o={};
  var name;
  var i=0;
  while (i<sheets.length) {
    var rules = sheets[i].rules || sheets[i].cssRules;
    var r=0;
    while(r<rules.length) {
          if(typeof(rules[r].style)!="undefined" &&
             !rules[r].selectorText.match(":before") &&   // fix for FF3.6
             !rules[r].selectorText.match(":after") &&
             !rules[r].selectorText.match(":link") &&
             !rules[r].selectorText.match(":hover") &&
             !rules[r].selectorText.match(":active") &&
             !rules[r].selectorText.match(":visited") &&
             !rules[r].selectorText.match(":first-letter") &&
             !rules[r].selectorText.match(":-moz-focus-inner") &&
              a.is(rules[r].selectorText)) {
              o = $.extend(o, css2json(rules[r].style), css2json(a.attr('style')));
          }
        r++;  
      }
    i++;
  }
  return o;
}

function css2json(css){
  var s = {};
  if(!css) return s;

  var isMSIE = /*@cc_on!@*/0;

  if (isMSIE)
      {
        if(typeof(css)=="object")
          {
            for(var i in css) {
              if(i.toLowerCase) 
                s[i.toLowerCase()] = css[i];
            }
          }
        else if(typeof css == "string")
          {
            css = css.split("; ");          
            for (var i in css) {
              var l = css[i].split(": ");
              s[l[0].toLowerCase()] = (l[1]);
            };
          }
      }
    else
      {
        if(css instanceof CSSStyleDeclaration)
          {
            for(var i in css) {
              if((css[i]).toLowerCase)
                s[(css[i]).toLowerCase()] = (css[css[i]]);
            }
          }
        else if(typeof css == "string")
          {
            css = css.split("; ");          
            for (var i in css) {
              var l = css[i].split(": ");
              s[l[0].toLowerCase()] = (l[1]);
            };
          }              
      }
  return s;
}



...           
alert(css($('some selector')).height); 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T04:30:34+00:00Added an answer on May 24, 2026 at 4:30 am

    Using the functions provided in this answer, you can access the height of the element like this:

    css($('div')).height
    

    Those functions account for both inline and inherited styles, which I believe is what you want. In the event that the height has not been explicitly specified, the height property of the returned object will be undefined.

    Demo

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am new to using jquery and would like to know how to append
I am using JQuery, and I would like to know if the remove() method
I would like to know what guys are using to make diagram of your
I would like to know if I can open 2 different diagrams using MS
I would like to know what the pros and cons are for using an
I would like to know what is the best practice between using bind tag
I would like to know how threads are handled on the server side using
I would like to know a way to create an XML file using MySQL
Using Commons beanUtils I would like to know how to ask any converter say
Our customer would like to know who is online and currently using the custom

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.