Dreamweaver CS6 -如何在鼠标悬停时停止滑块

Dreamweaver CS6 - How do I stop slider on mouseover?

本文关键字:悬停 鼠标 CS6 Dreamweaver      更新时间:2023-09-26

下面是jquery代码。我想知道在代码中如何以及在哪里我必须输入函数,当我越过滑块时,它会暂停滑动。然后当我把鼠标移出滑块,它会继续滑动照片。

$(document).ready(function() {
    $('.photo').hover(function() {
        $(this)
            .find('.caption')
            .stop()
            .animate({
                bottom: '0'
            }, {
                duration: 2000,
                easing: 'easeOutQuart'
            });
    }, function() {
        $(this)
            .find('.caption')
            .stop()
            .animate({
                bottom: '-100px'
            }, {
                duration: 2000,
                easing: 'easeOutQuart'
            });
        var interval = setInterval(slideSwitch, 2000);
    });
});

你可以使用jQuery的hover()函数作为快捷方式:

$(function() {
    var interval = setInterval( slideSwitch, 10000 );
    $('#slideshow').hover(function() {
        clearInterval(interval);
    }, function() {
        interval = setInterval( slideSwitch, 10000 );
    });
});