What is the Dojo equivalent of jQuery innerHeight ()?

In jQuery, we can use innerHeight to get the height of a single element (including padding, but not border).

$("selector").innerHeight();

How to get the same value using dojo?

What my solution uses

dojo.contentBox() //get the height of content box
dojo.style(node, "borderTopWidth") //get width of border-top
dojo.style(node, "borderBottomWidth"). //get width of border-left

Is there an easy way to do this?

+5
source share
1 answer

Unfortunately, I do not think there is an easier way to do this.

You basically have three options:

dojo.contentBox(node) // excludes border, padding and margin
dojo.position(node)   // includes border and padding; excludes margin
dojo.marginBox(node)  // includes border, padding and margin

So you need to do what you suggested. Use dojo.contentBox(), then separately calculate the width of the upper and lower borders.

<div> <div>, div div. dojo.position() div.

<div id="outer" style="border: solid #000 1px;">
  <div id="inner" style="height: 20px; padding: 2px;">.</div>
</div>
<script>
  alert(dojo.position("inner").h) // 24
</script>
+1

All Articles