0

Is there a way in javascript to determine wether the height of the Div is in %

<div id="dvPercentage" style="height: 80%">

How do I get that the height of the div was given in Percentage.

Pratim
  • 75
  • 1
  • 10
  • See this http://stackoverflow.com/questions/744319/get-css-rules-percentage-value-in-jquery – George Kagan Sep 15 '13 at 11:45
  • Basically you mean to say there's no way ? – Pratim Sep 15 '13 at 11:48
  • Seems like it. Anyhow, it is a feasible solution. – George Kagan Sep 15 '13 at 11:50
  • @timeNomad This doesn't apply because Pratim is asking about a property set in the style attr of the element not in a style sheet. See my answer below. – DutGRIFF Sep 15 '13 at 11:53
  • 1
    @timeNomad Well, it is a bit different for inline/own styles vs. the stylesheet/inherited styles asked about in that question. But, yes, those are generally limited to [*computed*](https://developer.mozilla.org/en-US/docs/Web/API/window.getComputedStyle) or [*used*](https://developer.mozilla.org/en-US/docs/Web/CSS/used_value) values. – Jonathan Lonowski Sep 15 '13 at 11:54
  • Ill do but wait ill test first :) :) – Pratim Sep 15 '13 at 12:08

2 Answers2

0

Just access the the height of the style object of the element.

document.getElementById("objectId").style.height
DutGRIFF
  • 5,103
  • 1
  • 33
  • 42
0

This will give back true

document.getElementById('dvPercentage').style.height.endsWith('%')

if height is in percent.

Marc
  • 1,900
  • 14
  • 22