jq如何實現內容的無限滾動
阿新 • • 發佈:2018-02-05
script ava 如何實現 log highlight set absolut hidden rip
html:
<div> <ul> <li>1</li> <li>2</li> <li>3</li> <li>4</li> <li>5</li> <li>1</li> </ul> </div>
css:
* { margin: 0; padding: 0; } div { width: 100px; height: 20px; overflow: hidden; border: 1px solid red; margin: 100px auto; position: relative; } li { height: 20px; } ul { position: absolute; left: 0; top: 0 }
js:
$(() => { let num = 0; setInterval(() => { num = $("ul").offset().top - 1; if (num === 1) { num = 101; } $("ul").offset({top: num}); }, 20) })
jq如何實現內容的無限滾動