skip to Main Content

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

Is there any way to get the sidebar height?

2

Answers


  1. 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
    
    Login or Signup to reply.
  2. 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.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search