1

What I'm trying to do is, whenever we leave the button and then move back to the grey content box, the slideUp will stop and the content will be slideDown again.

It works just fine using jQuery 1.x (edge), but when I use jQuery 1.10 the slideUp just stop, and not continue to slideDown again.

Do you guys have any idea which part should I change to make it work on jQuery 1.10?

$(function () {
    var show_content = '';

    $('.nav-content > div').hide();

    $('.btn1,.btn2').mouseenter(function (e) {
        var target = $(e.currentTarget).attr('class');
        console.log('Mouse Enter : ' + target);

        if (target == 'btn1') {
            show_content = $('.con1');
        } else if (target == 'btn2') {
            show_content = $('.con2');
        }
        show_content.stop().slideDown(300);
    });

    $('.btn1,.btn2').mouseleave(function (e) {
        var target = $(e.currentTarget).attr('class');
        show_content.stop().slideUp(2000);

    });

    $('.nav-content').mouseenter(function (e) {
        show_content.stop().slideDown(300);

    });
    $('.nav-content').mouseleave(function (e) {
        show_content.stop().slideUp(2000, 'swing', function (e) {
            console.log('Hide done');
        });
    });

});

Here's my Fiddle http://jsfiddle.net/PmJt2/2/

4

1 回答 1

1

我不知道为什么不再继续 slideDown,但 slideToggle 有效。

使用.slideToggle()代替 slideDown 和 slideUp

于 2013-11-08T22:42:10.103 回答