2013-10-23 99 views
0

我不想隱瞞我的提示,當鼠標在tooltip.but它應隱藏我們的鼠標了從工具提示。請幫我做這件事避免提示在鼠標懸停時

$(document).ready(function(){ 

    $('[rel=tooltip]').bind('mouseover', function() { 

    if ($(this).hasClass('ajax')) { 
     var ajax = $(this).attr('ajax'); 

     $.get(ajax, function(theMessage) { 
     $('<div class="tooltip">' + theMessage + '</div>').appendTo('body').fadeIn('fast'); 
     }); 
    } 
    else { 
     var theMessage = $(this).attr('content'); 
     $('<div class="tooltip">' + theMessage + '</div>').appendTo('body').fadeIn('fast'); 
    } 

    $(this).bind('mousemove', function(e) { 
     $('div.tooltip').css({ 
     'top': e.pageY - ($('div.tooltip').height()/2) - 5, 
      'left': e.pageX + 15 
     }); 
    }); 
    }).bind('mouseout', function() { 
    $('div.tooltip').fadeOut('slow', function() { 
     $(this).remove(); 
    }); 
    }); 
}); 

通訊(修剪) HTML,格式化垂直這裏更清楚地顯示屬性:

<a href="#" 
    alt="Image" 
    tooltip="" 
    rel="tooltip" 
    content="&lt;div id=imagcon&gt;&lt;img src=img/1.jpg class=tooltip-image/&gt;&lt;/div&gt;" 
>View Sonic</a> 
+0

Ummmmmmmm再說一遍? –

+0

你能提供相關的HTML嗎? – mc10

回答

0

你可以做的是去除從targetmouseout,而是可以綁定在提示DIV div.tooltip的mousout事件:

$('[rel=tooltip]').bind('mouseover', function(){ 
    ........... 
}); 

Then add this way: 

$(document).on('mouseout click', 'div.tooltip', function(){ 
    $('div.tooltip').fadeOut('slow', function(){ 
     $(this).remove(); 
    }); 

}); 

Checkout the demo fiddle here

+0

我想這不工作:(......這個時候DIV不是躲在點擊also.i要隱藏點擊 – dvirus

+0

該div @deepak看你是否使用'。對()'jQuery的方法放置多個事件看。 – Jai

+0

沒有成功但..看到小提琴鏈接!你的情況,你可以找到瀏覽器的錯誤控制檯瀏覽器控制檯 – dvirus

相關問題