How can we get height of sidebar in checkout using js
Is there any way to get the sidebar height?
2
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 :
clientHeight
getBoundingClientRect().height
myEl.getBoundingClientRect().height
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.
Click here to cancel reply.
2
Answers
first grab the element
then you can either check the height with
clientHeight
orgetBoundingClientRect().height
:You can get the height with offsetHeight and offsetWidth properties of the element.
then check the height with offsetHeight
The function will give you relatively with properties of the DOM element to get its the width and height.