0
Thanks

A few words of thanks would be greatly appreciated.

Javascript - Modifying the height of element HTML





Intro


The style property : height can be used to modify the height of an html element in javascript.

Implementation


For this you can refer to the following:
  • Below is an indication of how to do this modification.
  • If you want to know the height (height) of an HTML block, there are two ways depending on the browsers:
  • Below are two ways for displaying the height of an HTML block by browsers:

element.offsetHeight 
element.style.pixelHeight
  • Another way to display the height of an HTML block, but this time,regardless of the browsers:


var height = document.getElementById('id_element').style.height; 
  • If you wish to modify this property, you should specifypx. Thus the code for obtaining the height on HTML blog depending on the blog:


<script type="text/javascript">
<!--
var obj = document.getElementById('id_element');
obj.style.height = "502px";
//--></ital>
</script>
  • If you wish to retrieve the value of the height, you should set px to this value :


<script type="text/javascript">
<!--
var obj = document.getElementById('id_element');
obj.style.height = height+"px";
//-->
</script>
0
Thanks

A few words of thanks would be greatly appreciated.

Ask a question
CCM is a leading international tech website. Our content is written in collaboration with IT experts, under the direction of Jeff Pillou, founder of CCM.net. CCM reaches more than 50 million unique visitors per month and is available in 11 languages.

Published by . Latest update on by jak58.

This document, titled "Javascript - Modifying the height of element HTML," is available under the Creative Commons license. Any copy, reuse, or modification of the content should be sufficiently credited to CCM (https://ccm.net/).

0 Comments