jQuery Mobile 事件
事件 = 網(wǎng)頁能夠響應(yīng)的所有不同訪客的動作。
jQuery Mobile 事件
您能夠在 jQuery Mobile 中使用任何標(biāo)準(zhǔn)的 jQuery 事件。
此外,jQuery Mobile 還提供若干種為移動瀏覽定制的事件:
- 觸摸事件 - 當(dāng)用戶觸摸屏幕時觸發(fā)(敲擊和滑動)
- 滾動事件 - 當(dāng)上下滾動時觸發(fā)
- 方向事件 - 當(dāng)設(shè)備垂直或水平旋轉(zhuǎn)時觸發(fā)
- 頁面事件 - 當(dāng)頁面被顯示、隱藏、創(chuàng)建、加載以及/或卸載時觸發(fā)
如需關(guān)于所有 jQuery Mobile 事件的完整信息,請訪問我們的 jQuery Mobile 事件參考手冊。
初始化 jQuery Mobile 事件
在 jQuery 中,您已經(jīng)學(xué)到使用文檔 ready 事件來阻止 jQuery 代碼在文檔結(jié)束加載 (is ready) 前運行:
jQuery document ready 事件
<script>
$(document).ready(function(){
// 此處是 jQuery 事件...
});
</script>
然而,在 jQuery Mobile 中,我們使用 pageinit 事件,該事件在頁面已初始化并完善樣式設(shè)置后發(fā)生。
第二個參數(shù)指向 ("#pageone") 指向頁面的 idpoints to the id of the page to specify the events for:
jQuery Mobile pageinit 事件
<script> $(document).on("pageinit"
,"#pageone"
,function(){ // 此處是 jQuery 事件... }); </script>
注釋:jQuery on() 方法用于添加事件處理程序。
下幾章將詳解每個 jQuery Mobile 事件。