https://www.php.cn/link/45d0bb417c9fab94dae50e5974f30ec7
//D = document //W = window //$ = jQuery var contentArea = $(this), wintop = contentArea.scrollTop(), docheight = $(D).height(), winheight = $(W).height(), divheight = $('#content').height(), scrollheight = $('#content')[0].scrollHeight, scrolltrigger = 0.9; console.log('wintop ' + wintop); console.log('docheight ' + docheight); console.log('winheight ' + winheight); console.log('divheight ' + divheight); console.log('scrollheight ' + scrollheight); console.log((wintop + divheight)/scrollheight); if (((wintop + divheight)/scrollheight) > scrolltrigger) { // 显示滚动条 }
기능을 사용할 수 있습니다. 예는 다음과 같습니다. overflow
<,>이 예에서 "Divid"를 DIV의 ID로 바꾸십시오. 이것은 2 초 안에 DIV로 부드럽게 스크롤됩니다. auto
scroll
auto
<,>이 예에서 "Divid"를 DIV의 ID로 바꾸십시오. 이렇게하면 내용이 DIV보다 큰 경우 DIV에 스크롤 바를 추가합니다. scroll
$("#divID").css("overflow", "auto");
<,>이 예에서 "Divid"를 DIV의 ID로 바꾸십시오. 이것은 2 초 안에 DIV로 부드럽게 스크롤됩니다.
animate
scrollTop
<,>이 예에서 "Divid"를 DIV의 ID로 바꾸십시오. 이것은 div의 스크롤 바를 숨길 것입니다.
를 <🎜 🎜> 또는 <🎜 🎜>와 비교할 수 있습니다. <🎜 🎜> 또는 scrollHeight
가 더 크면 DIV에는 스크롤 막대가 있습니다. 예는 다음과 같습니다. scrollWidth
<,>이 예에서 "Divid"를 DIV의 ID로 바꾸십시오. DIV에 수직 스크롤 바가 있는지 확인합니다. clientHeight
clientWidth
scrollHeight
속성을 scrollWidth
로 변경할 수 있습니다. 예는 다음과 같습니다.
//D = document //W = window //$ = jQuery var contentArea = $(this), wintop = contentArea.scrollTop(), docheight = $(D).height(), winheight = $(W).height(), divheight = $('#content').height(), scrollheight = $('#content')[0].scrollHeight, scrolltrigger = 0.9; console.log('wintop ' + wintop); console.log('docheight ' + docheight); console.log('winheight ' + winheight); console.log('divheight ' + divheight); console.log('scrollheight ' + scrollheight); console.log((wintop + divheight)/scrollheight); if (((wintop + divheight)/scrollheight) > scrolltrigger) { // 显示滚动条 }
이 예에서 "Divid"를 DIV의 ID로 바꾸십시오. 이것은 div의 바닥으로 스크롤됩니다. css
위 내용은 jQuery div에 스크롤 바를 추가합니다의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!