How can I determine the height of a horizontal scrollbar, or the width of a vertical one, in JavaScript?
相关问题
- Is there a limit to how many levels you can nest i
- How to toggle on Order in ReactJS
- void before promise syntax
- Keeping track of variable instances
- Can php detect if javascript is on or not?
Using jQuery, you can shorten Matthew Vines answer to:
I found a simple solution that works for elements inside of the page, instead of the page itself:
$('#element')[0].offsetHeight - $('#element')[0].clientHeight
This returns the height of the x-axis scrollbar.
For me, the most useful way was
with vanilla JavaScript.
This life-hack decision will give you opportunity to find browser scrollY width (vanilla JavaScript). Using this example you can get scrollY width on any element including those elements that shouldn't have to have scroll according to your current design conception,: