各位大佬:
我有一段js代碼,使用的是 jquery的animate 方法,我需要在這段代碼運(yùn)行時(shí),
監(jiān)聽(tīng)鼠標(biāo)滾輪的動(dòng)作,如果有鼠標(biāo)滾輪的動(dòng)作,就退出這個(gè)animate方法,請(qǐng)教怎么寫(xiě)代碼?
?
附:
window.onload = function () { ? ? ? ?setTimeout(autorollup,3000); ? ?function autorollup(){ ? ? ? ?$("#part2").animate({top: "-=800px"}, 8000); ? ?}
感謝不吝賜教!
添加事件監(jiān)聽(tīng)即可,window.addEventListener("wheel", 回調(diào)函數(shù));