Javascript 如何在悬停时从多个选项中清除所选变量
小提琴: 脚本:Javascript 如何在悬停时从多个选项中清除所选变量,javascript,jquery,Javascript,Jquery,小提琴: 脚本: ... $(this).parent().mouseover(function () { if (settings.pauseOnHover == 1) { clearInterval(po); } }).mouseout(function () { po = setInterval(function () { AutoSlide($(this)) }.bind(this), settings.timeoutSet); }); ...
...
$(this).parent().mouseover(function () {
if (settings.pauseOnHover == 1) {
clearInterval(po);
}
}).mouseout(function () {
po = setInterval(function () { AutoSlide($(this)) }.bind(this), settings.timeoutSet);
});
...
我遇到的问题是,当鼠标悬停在任何一个滑块上时,它不会暂停该滑块,而是两个滑块开始随机动作
如何更新脚本,以便如果我将鼠标悬停在第一个滑块上,它将仅暂停该滑块,而第二个滑块将继续;如果我将鼠标悬停在第二个滑块上,它将仅暂停该滑块,而第一个滑块将从暂停的位置继续,依此类推。您需要绑定mouseout回调函数
$(this).parent().mouseover(function () {
if (settings.pauseOnHover == 1) {
clearInterval(po);
}
}).mouseout(function () {
po = setInterval(function () { AutoSlide($(this)) }.bind(this), settings.timeoutSet);
}.bind(this)); // <<-- TRY THIS
$(this.parent().mouseover(函数(){
如果(settings.pauseonhaver==1){
净距(po);
}
}).mouseout(函数(){
po=setInterval(函数(){AutoSlide($(this))}.bind(this),settings.timestart);
}.绑定(此));// 你能这样试试吗
var _this = $(this);
$(this).parent().mouseover(function () {
if (settings.pauseOnHover == 1) {
clearInterval(po);
}
}).mouseout(function () {
po = setInterval(function () { AutoSlide($(_this)) }.bind(_this), settings.timeoutSet);
});
非常感谢,它成功了。我会接受你的回答,因为它有点短:)。