3

jQuery で「マウスオーバー」機能を使用すると問題が発生します。

要素にマウスを合わせるのが速すぎると、「mouseleave」機能が失われ、要素は自分自身を削除しません...

私の JSFiddle : http://jsfiddle.net/tonymx227/4YRuf/5/

私のコード:

$('figure').children('img').on('mouseover', function(e){
    $(this).parent().append('<div id="figure-over"><a href="'+$(this).parent().data('url')+'" target="_blank">Voir</a></div>');
    $(this).parent().children('#figure-over').stop().slideDown();
    $(this).parent().children('#figure-over').on('mouseleave', function(){
        $(this).stop().slideUp( function(){
            $(this).remove();
        });
    }).on('click', function(){
        window.open($(this).children('a').attr('href'));
    });
});
4

2 に答える 2