Home > Back-end >  How to find height of sidebar in checkout page using js
How to find height of sidebar in checkout page using js

Time:10-15

How can we get height of sidebar in checkout using js enter image description here

Is there any way to get the sidebar height?

CodePudding user response:

first grab the element

const myEl = document.querySelector("#whatever-your-sidebar-id-is");

then you can either check the height with clientHeight or getBoundingClientRect().height :

myEl.getBoundingClientRect().height

CodePudding user response:

You can get the height with offsetHeight and offsetWidth properties of the element.

elem = document.querySelector('#sidebar-id-or-class')

elem = document.querySelector('.cart-summary')

then check the height with offsetHeight

console.log(elem.offsetHeight)

The function will give you relatively with properties of the DOM element to get its the width and height.

  • Related