我想在鼠标悬停时尝试图像幻灯片放映,并在鼠标悬停时停止
以下是我的代码:但是将鼠标悬停在鼠标上时也会调用..它在chrome上工作正常...
default_image = '';
timer = 0;
jQuery('.sales-product-images').on('mouseover',function(){
var counter = 0;
var selector = jQuery(this);
var pd_id = jQuery(this).attr('id');
var imageArray = jQuery.parseJSON(images);
var product_images= imageArray[pd_id];
default_image = jQuery(this).attr('data-image');
console.log('default-image= ' + default_image);
timer = setInterval(function(){selector.fadeOut("fast", function () {
console.log(counter);
if (counter === product_images.length) {
console.log('==');
counter = 0;
}
console.log('localhost/product/' + product_images[counter]);
selector.attr('src', 'localhost/product/' + product_images[counter]);
selector.fadeIn(2500);
counter = counter+ 1;
});
}, 2000)});
jQuery('.sales-product-images').on('mouseleave', function() {
console.log('now end');
// var counter = 0;
clearInterval(timer);
)};
问题是:在firefox中的鼠标悬停上也印有“ now end”。不应这样。
最佳答案
尝试这个 :
jQuery('.sales-product-images').on('mouseout', function() {
console.log('now end');
// var counter = 0;
clearInterval(timer);
)};
关于javascript - Mouseover和mouseout在Firefox上不起作用?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/28337891/