【发布时间】:2017-12-16 10:21:12
【问题描述】:
jQuery:
$(document).on('mouseover', '.image_slider', function() {
setInterval(slider(this), 10000);
});
function slider(that){
console.log(that);
}
谁能告诉我为什么这个功能不起作用,我该如何解决?
【问题讨论】:
标签: javascript
jQuery:
$(document).on('mouseover', '.image_slider', function() {
setInterval(slider(this), 10000);
});
function slider(that){
console.log(that);
}
谁能告诉我为什么这个功能不起作用,我该如何解决?
【问题讨论】:
标签: javascript
window.setInterval 在给定时间后执行参数。因此你应该这样执行它:
setInterval ( myFunction, 1000 );
或者
$(document).on('mouseover', '.image_slider', function() {
setInterval(function (e){
slider (this)
}.bind (this), 10000);
});
function slider(that){
console.log(that);
}
【讨论】: