Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the Dojo equivalent of jQuery's innerHeight()?

Tags:

dojo

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

$("selector").innerHeight();

How can I get the same value by dojo?

What my solution is using

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 any easy way to do it?

like image 497
init.Monk Avatar asked Nov 13 '22 10:11

init.Monk


1 Answers

Unfortunately, I don't think there is an easier way to do it.

You basically have three choices:

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 top and bottom border widths.

Alternatively you might want to place a <div> inside a <div>, so that you can set the border on the outer div and keep the padding on the inner div. You would then be able to get the required height from calling dojo.position() for the inner 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>
like image 147
SimonMayer Avatar answered Jun 15 '23 11:06

SimonMayer