0

I need to get the width of this div

<div class='row WidthAdjust'></div>

But it is proving way more difficult than I anticipated, below is some of the things I have already tried

  // var row = document.getElementsByClassName("WidthAdjust").width()
      var row = document.getElementsByClassName("WidthAdjust")
      var rowWidth = parseFloat($(row).width())
Ross Symonds
  • 690
  • 1
  • 8
  • 29
  • https://stackoverflow.com/questions/4787527/how-to-find-the-width-of-a-div-using-vanilla-javascript – Pine Code Jan 20 '22 at 13:19
  • 1
    Does this answer your question? [How to find the width of a div using vanilla JavaScript?](https://stackoverflow.com/questions/4787527/how-to-find-the-width-of-a-div-using-vanilla-javascript) – Aous Mohammad Jan 20 '22 at 13:22

1 Answers1

1

You can use var data = row.getBoundingClientRect() to get DOMRect object. This object will have the size of the element and its position relative to view port.

Use data.width to get the width specifically.

Yashwardhan Pauranik
  • 5,370
  • 5
  • 42
  • 65