0

div (.modal) をマウスアウトで非表示にしたいのですが、ホバーが .modal または .tooltip クラスにない場合のみです。

私のコード:

    jQuery('html').hover(function() {
        jQuery('.modal').fadeOut('fast');
    });        
    jQuery('.tooltip, .modal').hover(function(event){  
        var toolTipId = jQuery(this).attr('id'); 
            modal = jQuery(this).parent().next().find('.'+toolTipId+'');          
        if(!modal.is(":visible")) {
            modal.stop().fadeIn('fast');
        }
        event.stopPropagation();
    });

ホバーの代わりにクリックを使用する場合、これは完璧に機能します。これをホバーで動作するように適応させるにはどうすればよいですか?

4

1 に答える 1

1

あなたはこのようなことをすることができます:

jQuery('.tooltip, .modal').mouseenter(function(event){  
    //not sure what your modal variable is in your original code but it looks as if it is just the object you are hovering as you use it's id to get it in again so I replaced it with jQuery(this)
    if(!jQuery(this).is(":visible")) {
        jQuery(this).stop().fadeIn('fast');
    }
    event.stopPropagation();
});

jQuery('.tooltip, .modal').mouseleave(function() {
    jQuery(this).stop().fadeOut('fast');
});
于 2013-03-11T14:46:58.727 に答える