Get Innerheight-Outerheight-Scrollheight Clientheight using JavaScript

Get Innerheight-Outerheight-Scrollheight Clientheight using JavaScript

In this Post We Will Explain About is Get Innerheight-Outerheight-Scrollheight Clientheight using JavaScript With Example and Demo.Welcome on Pakainfo.com – Examples, The best For Learn web development Tutorials,Demo with Example! Hi Dear Friends here u can know to Setting DIV width and height in JavaScriptExample

In this post we will show you Best way to implement Detect Scrollbar Width with JavaScript, hear for Detect set height of div to height and Width with JavaScriptwith Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!.

Read Also:  Vue 2.0 Hello World Step By Step

Example 1 : Getting width and height of an element

var height = document.getElementById('mylivedivid').clientHeight;
var height = document.getElementById('mylivedivid').scrollHeight;
var height = document.getElementById('mylivedivid').scrollHeight;

Example 2 : INNER HEIGHT:

document.getElementById(your_id_attribute_value).clientHeight;

Example 3 : OUTER HEIGHT:

 
document.getElementById(your_id_attribute_value).offsetHeight; 

Example 4 : Getting the height of a div usinf jQuery Example

 
//if we need height of div excluding just margin/padding/border
$('#mylivedivid').height();

//if we need just height of div with padding all and but without simple border + margin
$('#mylivedivid').innerHeight();

// if we need height of div including just padding and border
$('#mylivedivid').outerHeight();

//and at last for simple including just simple border + margin + padding as well as can use
$('#mylivedivid').outerHeight(true);

offsetHeight includes padding default, scrollBar and your borders.clientHeight just includes padding.

Example 5 : pure javascript to get height

 
<div id="liveitem">show your live height</div>
<script>
    alert(document.getElementById('liveitem').offsetHeight);
</script>

Example 6 : Dynemic set width using javascript

 
document.getElementById('div_login').setAttribute("style","width:600px");

Example 7 : Get and set scroll position of an element

 
var temp = document.querySelector('div');

// get simple scroll position in px
console.log(temp.scrollLeft, temp.scrollTop);

// set simple scroll position in px
temp.scrollLeft = 500;
temp.scrollTop = 1000;

Example 8 :Get scrollbar width using pure javascript DOM Elements

HTML part

 
 <div id="outter" style="width: 400px; overflow-y: scroll;">
  <div id="inner" style="height: 50px; border: 1px solid black;"></div>
</div>

script part

 
let scrollbarWidth = outter.offsetWidth - inner.offsetWidth;
inner.innerHTML = "Scrollbar width: " + scrollbarWidth;

Example

I hope you have Got What is jquery set height of div to height of another div And how it works.I would Like to have FeadBack From My Blog(Pakainfo.com) readers.Your Valuable FeadBack,Any Question,or any Comments abaout This Article(Pakainfo.com) Are Most Always Welcome.