Adding a delay on mouseout with jquery

I'm writing a function to fire a fadein - fadeout effect on mouseover / mouseout, all works right, but now I need to add a delay on mouseout. When the mouse hovering a link the div related has to fadein and the other ones need to fadeout.

I try many times without any success...

Here's the code:

function selectedSwitch() {
            $('.selectedSwitch').each(function() {
                $(this).on("mouseover", function(e) {
                    e.preventDefault();
                    var current = $(this).data('selected');
                    $('.selected.post-'+current).stop().animate({'opacity': 1}, 200);
                    $('.selected.post-'+current).siblings().stop().animate({'opacity': 0}, 200);
                });
                $(this).on("mouseout", function(e) {
                    e.preventDefault();
                    var current = $(this).data('selected');
                    $('.selected.post-'+current).stop().animate({'opacity': 0}, 200);
                });
            });
    }

Thanks so much!


您不能延迟触发事件,但可以在使用setTimeout函数执行的代码中添加延迟

链接地址: http://www.djcxy.com/p/21396.html

上一篇: 控制并转换为XPS

下一篇: 使用jquery在mouseout上添加延迟