scroll
英[skr??l]? ?美[skro?l]??
n.(常用來(lái)錄寫正式文件的)紙捲;書卷,畫卷,捲軸;渦卷形(裝飾);〈古〉表,目錄
vt.使成捲形;(電腦螢?zāi)簧希纳系较乱苿?dòng)(資料等),卷頁(yè)
vi .(似捲軸般)捲起;(像展開捲軸般地)將文字顯示於螢?zāi)?/p>
jquery scroll()方法 語(yǔ)法
作用:當(dāng)使用者捲動(dòng)指定的元素時(shí),會(huì)發(fā)生 scroll 事件。 scroll 事件適用於所有可捲動(dòng)的元素和 window 物件(瀏覽器視窗)。 scroll() 方法觸發(fā) scroll 事件,或規(guī)定發(fā)生 scroll 事件時(shí)運(yùn)行的函數(shù)。
觸發(fā)scroll事件:$(selector).scroll()
將函數(shù)綁定到scroll事件:$(selector ).scroll(function)
參數(shù):
參數(shù) | 描述 |
function? ?? | #可選。規(guī)定發(fā)生 scroll 事件時(shí)運(yùn)行的函數(shù)。 |
jquery scroll()方法 範(fàn)例
<html> <head> <script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/2.1.1/jquery.min.js"></script> <script type="text/javascript"> x=0; $(document).ready(function(){ $("div").scroll(function() { $("span").text(x+=1); }); }); </script> </head> <body> <p>請(qǐng)?jiān)囍鴿L動(dòng) DIV 中的文本:</p> <div style="width:200px;height:100px;overflow:scroll;">text. text. text. text. text. text. text. text. text. text. text. text. text. text. text. text. text. text. text. text. text. text. <br /><br /> text. text. text. text. text. text. text. text. text. text. text. text. text. text. text. text. text. text. text. text. text. text. text. text. text. text. text. text. text. text. text. text. text.</div> <p>滾動(dòng)了 <span>0</span> 次。</p> </body> </html>
#點(diǎn)擊 "執(zhí)行實(shí)例" 按鈕查看線上實(shí)例