2013-02-12 56 views
0

我有一個懸停的問題。他們在IE中工作正常,但不是Mozilla Firefox或Chrome。我猜這是因爲它很模糊,每td但現在這就是我需要的。這裏的小提琴(不工作)http://jsfiddle.net/233qG/在此先感謝。jQuery懸停只適用於Internet Explorer

的HTML

<table> 
    <tr> 
     <td>one</td> 
    </tr> 
    <tr> 
     <td>two</td> 
    </tr> 
    <tr> 
     <td>three</td> 
    </tr> 
</table> 
<div class="modalPop">Modal Information</div> 

的CSS

div.modalPop 
{ 
    display:none; 
    position:absolute; 
    border:solid 1px black; 
    padding:8px; 
    background-color:white; 
    margin: 280px 50px 0 0; 
    z-index: 9999; 
} 
a.modalPop:hover + div.modalPop 
{ 
    display:block; 
} 
div.modalPop:hover 
{ 
    display:block; 
} 

jQuery的

$(document).ready(function(){ 
    $('td').hover(
     function(){$('.modalPop' + this).stop().hide().fadeIn('slow');}, 
     function(){$('.modalPop' + this).stop(true, true).fadeOut('slow');} 
    ); 
}); 
+0

'$'???將一個元素添加到字符串中。我驚訝它可以在任何地方工作? – adeneo 2013-02-12 16:15:08

+0

我沒有看到'a.modalPop'元素... – Christoph 2013-02-12 16:15:19

+0

你甚至看過你的控制檯錯誤嗎? – Sparky 2013-02-12 16:15:47

回答

8

$('.modalPop' + this)是無效的。 this是一個對象。你正試圖用一個對象連接一個字符串。只需使用$('.modalPop')

如果您在控制檯上打開(鉻工具或螢火蟲),你應該看到類似這樣的錯誤:

Uncaught Error: Syntax error, unrecognized expression: .modalPop[object HTMLTableCellElement]

坦率地說,我不明白爲什麼它甚至在IE工作。你爲什麼將this添加到字符串?

1

我想你的意思是這樣的:( 'modalPop' +本)

$('td').hover(
    function(){$('.modalPop').stop().hide().fadeIn('slow').html("Modal Information : " + $(this).text());}, 
    function(){$('.modalPop').stop(true, true).fadeOut('slow');} 
); 

http://jsfiddle.net/233qG/3/

相關問題