0
我已經嘗試了很多,但不能添加顯示更多的按鈕後,每三個向下滾動自動。「查看更多」按鈕後,每三個底部滾動使用jQuery
當我要到我的頁面底部時,它向下滾動無限次。我必須在三次滾動後停止它,並且希望在每三次滾動後添加「查看更多」按鈕。
我已經嘗試了很多,但不能添加顯示更多的按鈕後,每三個向下滾動自動。「查看更多」按鈕後,每三個底部滾動使用jQuery
當我要到我的頁面底部時,它向下滾動無限次。我必須在三次滾動後停止它,並且希望在每三次滾動後添加「查看更多」按鈕。
嘗試這樣:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<!DOCTYPE html>
<html>
<head>
<style>
body {
width: 200px;
height: 100px;
overflow: scroll;
}
</style>
</head>
<body >
<p>Try the scrollbar in div.</p>
In my younger and more vulnerable years my father gave me some advice that I've been turning over in my mind ever since.
<br><br>
'Whenever you feel like criticizing anyone,' he told me, just remember that all the people in this world haven't had the advantages that you've had.'
<p>Try the scrollbar in div.</p>
In my younger and more vulnerable years my father gave me some advice that I've been turning over in my mind ever since.
<br><br>
'Whenever you feel like criticizing anyone,' he told me, just remember that all the people in this world haven't had the advantages that you've had.'
<p>Try the scrollbar in div.</p>
In my younger and more vulnerable years my father gave me some advice that I've been turning over in my mind ever since.
<br><br>
'Whenever you feel like criticizing anyone,' he told me, just remember that all the people in this world haven't had the advantages that you've had.'
<p>Try the scrollbar in div.</p>
In my younger and more vulnerable years my father gave me some advice that I've been turning over in my mind ever since.
<br><br>
'Whenever you feel like criticizing anyone,' he told me, just remember that all the people in this world haven't had the advantages that you've had.'
<p>Scrolled <span id="demo">0</span> times.</p>
<script>
var lastScrollTop = 0;
var x = 0;
$(window).scroll(function(event){
var st = $(this).scrollTop();
if (st > lastScrollTop){
\t document.getElementById("demo").innerHTML = x += 1;
\t if(x%3 == 0){
\t \t var i=document.createElement('button');
\t \t i.innerHTML="more";
\t document.getElementsByTagName('body')[0].appendChild(i);
\t }
}
lastScrollTop = st;
});
</script>
</body>
</html>
你有什麼迄今所做?也許你可以發佈你的代碼? – artsylar