Example:

$(el).css("height"); 

does not fit, as it just gets the size of the height of the window. Need to get exactly the value of the styles. That is, in the styles indicated exactly height: calc(100vh - 49px); and the script simply returns the block size in px.

    1 answer 1

    Well, something like this:

     $(function() { var ss = document.styleSheets[0]; var rules = ss.cssRules || ss.rules; var h1Rule = null; for (var i = 0; i < rules.length; i++) { var rule = rules[i]; if (/(^|,) *h1 *(,|$)/i.test(rule.selectorText)) { h1Rule = rule; break; } } console.log(h1Rule.style.height) }); 
     h1 { height: calc(100vh - 49px); } 
     <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <h1>Header</h1> 

    • Thank. Is it a parser type? Does he take a lot of memory? I have a very large script and a lot of styles are connected on the page, and their order is also unknown. - Vladimir
    • one
      No, it's just a brute force for the data used - Crantisz
    • Thank you very much, you are a pro) - Vladimir
    • The only thing, if you have several similar selectors, it will search only in the first one found. Those. in this case it will be necessary to refine the code - Crantisz
    • Thank you, I'm just finalizing. The main thing is that even though I know where to dance. - Vladimir