我想刪除一個類focus-mode
當用戶滾動頁面或者用鼠標滾輪或滾動條:什麼是滾動頁面的jQuery事件?
$("#input-content").on("SCROLLING_EVENT", function(e) {
$(".chapter-form").toggleClass("focus-mode");
});
但我無法找到,網上什麼。 jQuery是否有滾動事件?如果不是,那麼我最想達到的目標是什麼?
我想刪除一個類focus-mode
當用戶滾動頁面或者用鼠標滾輪或滾動條:什麼是滾動頁面的jQuery事件?
$("#input-content").on("SCROLLING_EVENT", function(e) {
$(".chapter-form").toggleClass("focus-mode");
});
但我無法找到,網上什麼。 jQuery是否有滾動事件?如果不是,那麼我最想達到的目標是什麼?
這是普通的舊"scroll"
。
.on("scroll", handler)
此方法是在第一 和第二變化。對用於快捷方式( 「滾動」,處理程序),和.trigger( 「滾動」)在第三。
$(window).scroll(function(){
$(".chapter-form").toggleClass("focus-mode");
});
此代碼會在您每次滾動時觸發。
使用scroll event一樣,
$(function(){
$('#input-content').scroll(function(e) {
$(".chapter-form").toggleClass("focus-mode");
});
});
'$(「#input-content」).roll(function(){....});'see here:http://api.jquery.com/scroll/ – Riad
http:// api.jquery.com/scroll/還要注意,這個事件觸發了*每一個像素*滾動,所以你的'focus-mode'類將在每個滾動上切換成數千次。 –