Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

javascript get element height and width

var width = document.getElementById('myID').offsetWidth;//includes margin,border,padding
var height = document.getElementById('myID'). offsetHeight;//includes margin,border,padding
Comment

width and height in js

const heightOutput = document.querySelector("#height");
const widthOutput = document.querySelector("#width");

function resizeListener() {
  heightOutput.textContent = window.innerHeight;
  widthOutput.textContent = window.innerWidth;
}

window.addEventListener("resize", resizeListener);
Comment

set width height of html using js

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
  </head>

  <body>
    <div id="box" style="background-color: salmon">Box 1</div>

    <script src="index.js"></script>
  </body>
</html>
Comment

PREVIOUS NEXT
Code Example
Javascript :: get children jquery index 
Javascript :: subtract dates javascript 
Javascript :: how do you make a random array in javascript 
Javascript :: jquery select element with two classes 
Javascript :: js get json keys 
Javascript :: slick slider multiple sliders on one page 
Javascript :: js format time 
Javascript :: hasownproperty 
Javascript :: check for alphabetic string in javascript 
Javascript :: javascript array functions 
Javascript :: inject image javascript 
Javascript :: how to get enum item name in javascript 
Javascript :: redux dev tools 
Javascript :: js styles when clicked 
Javascript :: pageyoffset jquery 
Javascript :: javascript is int in array 
Javascript :: sum all elements in array javascript 
Javascript :: REACT-ICONS reduce thickness 
Javascript :: random string from array javascript 
Javascript :: jquery find previous element with class 
Javascript :: how to display api data in html 
Javascript :: how to tell the javascript to wait until the site loads in the html 
Javascript :: VM1188:1 Uncaught TypeError: $ is not a function at <anonymous:1:1 
Javascript :: anonymous function jquery 
Javascript :: create array with number js 
Javascript :: disable global require eslint 
Javascript :: factorialization in javascript 
Javascript :: dynamically change css class with javascript 
Javascript :: how to trap js errors window.onerror 
Javascript :: Glide Ajax Client Script ServiceNow 
ADD CONTENT
Topic
Content
Source link
Name
7+4 =