2011-04-14 38 views
0

如何禁用JavaScript點擊和工具提示。Javascript幫助禁用列鏈接和工具提示

你可以看到這裏的問題http://www.vinderhimlen.dk/vind-rejse-deltag-i-konkurrencer-om-rejser

該評級列不應該顯示工具提示或者是鏈接。

它是安裝在我的tabels行:

<tr class="thumbnail-item" onclick="window.open('<%= vind.tracking %>')" onmouseout="this.style.background='white';" onmouseover="this.style.background='#99ff33';this.style.cursor='pointer'"> 

我的提示腳本:

<script type="text/javascript"> 


    $(document).ready(function() { 

$('.thumbnail-item').mouseenter(function(e) { 

    x = e.pageX; 
    y = e.pageY; 

    $(this).css('z-index','15') 
    $(this).css('cursor', 'default') 
    $(this).find(".tiptip").css({'top': y,'left': x,'display':'block'}); 


}).mousemove(function(e) { 

    x = e.pageX; 
    y = e.pageY; 

    $(this).find(".tiptip").css({'top': y,'left': x}); 

}).mouseleave(function() { 

    $(this).css('z-index','1') 
    $(this).css('background', 'none') 
    $(this).css('color', '#000000') 
    $(this).find(".tiptip").animate({"opacity": "hide"},100); 
}); 

}); 
    </script> 
+0

首先告訴我們你是怎麼連接這些事件。順便說一句:該評級插件不能在IE9中工作,我不得不在FF中打開它,看看你在說什麼專欄。 – Damb 2011-04-14 12:10:55

+0

我已經更新了我的問題,它附在我的行上。感謝讓我知道額定值插件不工作在IE – 2011-04-14 12:16:21

回答

0

您應該禁用鼠標懸停事件以冒泡。

我已經運行下面的腳本使用螢火蟲來實現結果。

$("#tabel1 tr td:nth-child(2):gt(0)") 
.mouseover(
       function(event) 
       { 
       event.preventDefault(); 
       return false; 
       }); 

編輯__ 當您的鼠標移動到工具提示,它不工作非常好。將光標移離工具提示一點點。

他是你計算鼠標點

x = e.pageX; 
y = e.pageY; 

你前人的精力在鼠標移動和鼠標懸停的兩個函數做這樣的

x = e.pageX+3; 
y = e.pageY+3; 

+0

當我從評估欄右側移動courser時,它變爲鏈接並顯示懸停圖像,這並非防彈。 – 2011-04-14 12:36:43

+0

我正在使用Jquery我已經用腳本更新了我的問題。通過從鼠標移開工具提示,我不知道你的意思。在.mousemove和.mouseleave中都有 – 2011-04-14 12:53:59

+0

? – 2011-04-14 13:07:26

0

很容易實際。您爲什麼不處理<td></td>標籤中的onmouseover/out事件,並將其保留在評級列上?

TR背景着色可以通過將僞類附加到tr標籤或.thumbnail-item類來實現。

tr:hover 
{ 
    background-color: #99FF33; 
} 
+0

因爲它會很混亂。 – 2011-04-14 12:20:00

+0

僅靠這一點是不夠的,因爲他在mouseover上着色整行背景。您只會着色一個單元格。 – Damb 2011-04-14 12:20:19

+0

然後處理行中的行着色,並在要處理的單元中處理鼠標懸停/跳出鏈接/工具提示。如果它變得「雜亂」,爲什麼不定義一個JavaScript函數,所以你只需要調用它。如果它工作有效,沒有人會看代碼?同樣,行着色可以用CSS pseudoclasses處理 – 2011-04-14 12:23:57