English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
Using jQuery to control the scroll bar to scroll and then judge whether the scroll bar has an offset. If there is, then there is a scroll bar, otherwise there is no scroll bar.
<script type="text/javascript"> $(function(){ $("body").scrollTop(10);//Control the scroll bar to move down10px if( $("body").scrollTop()>0 ){ alert("There is a scroll bar"); } alert("No scroll bar"); } $("body").scrollTop(0);//Scroll to the top of the scroll bar }); </script>
This simple method of judging whether there is a scroll bar in jQuery shared by the editor is all the content I want to share with everyone. I hope it can be a reference for everyone, and I also hope everyone will support the Yell Tutorial.