32

If a div is set as overflow:auto, how can I find out (using plain JS) if a scrollbar (Vertical / Horizontal) has been rendered?

KJ Saxena
  • 20,810
  • 24
  • 79
  • 106

1 Answers1

52

Check if clientHeight is smaller than scrollHeight.

Gh61
  • 8,457
  • 4
  • 26
  • 37
rahul
  • 179,909
  • 49
  • 229
  • 260
  • 4
    Finding every element on page that has a scrollbar `[...document.querySelectorAll('*')].filter(x => x.clientHeight < x.scrollHeight)` – A1rPun Aug 27 '19 at 08:35