2014-02-25 46 views
1

我有一個簡單的jquery程序,其中div應該根據懸停的評論時鼠標的座標 顯示。我不幸地使用event.clientX和event.clientY函數,這些函數在firefox瀏覽器中不起作用(firefox中的錯誤是「ReferenceError:event is not defined」)。在Chrome和IE中運行良好。請提供幫助。謝謝。firefox中的ClientX和ClientY參考錯誤?

<div class="comment"></div> 
<div class="commentBox"> 
<p>welcome</p> 
</div> 

$('.comment').hover(function(e){ 

    var x=event.clientX 
var y=event.clientY 
    x=x-263; 

$('.commentBox').css({"left":x+"px","top":y+"px"}); 


    $('.commentBox').css('visibility','visible'); 

    },function(e){ 


     $('.commentBox').css('visibility','visible'); 
    }); 
+0

您已經使用過函數中的懸停和使用事件內部的功能,這是問題的原因 –

回答

0
$('.comment').hover(function(e){ 

    var x=e.clientX;//replaced event with e 
    var y=e.clientY;////replaced event with e 

你必須參數e而不是event。所以你得到ReferenceError: event is not defined