2011-05-12 20 views
0

以下代碼使用jQuery 1.4.4和jQuery工具1.2.5。
無線電點擊,它在IE8中評估$(event.target).attr('id')爲'未定義'。也可能在其他版本的IE中。它在大多數其他瀏覽器上按預期工作。jQuery工具驗證器影響`event.target行爲`

當註釋掉$('form').validator()的實例時,代碼即使在IE上也按預期運行。

請指教。

<!DOCTYPE html> 
<html> 
<head> 
    <title>jquery tools validator and IE issue on event.target</title> 
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script> 
    <script src="http://cdn.jquerytools.org/1.2.5/full/jquery.tools.min.js?foo"></script> 
    <script> 
    $(document).ready(function(){ 
     $('form').validator(); 
     $('[type=radio]').click(function(event){ 
      alert($(event.target).attr('id')); 
     }); 
    }); 
    </script> 
</head> 
<body> 
    <form> 
     <input type="radio" name="aee-ee-eight" id="id-0" value="0" checked="checked" tabindex="0"> 
     <input type="radio" name="aee-ee-eight" id="id-1" value="0" tabindex="1"> 
     <input type="radio" name="aee-ee-eight" id="id-2" value="0" tabindex="2"> 
     <input type="submit"><br/> 
</form> 
</body> 
</html> 

回答

0

我覺得你的問題是使用event.target試試這個,而不是拿起目標值。

我會改變你的函數是:

$(document).ready(function(){ 
     $('form').validator(); 
     $('[type=radio]').click(function(){ 
      alert($(this).attr('id')); 
     }); 
    }); 
+0

嗯,這是真實的這個例子,但我的實際代碼是使用代理。點擊(MYPROXY(函數(事件),我沒有訪問「這個」 – 2011-05-12 14:40:31

+0

問題是,即不interpet event.target – Avitus 2011-05-12 14:42:16

+0

好,是不是jQuery的照顧?如果你註釋掉validator()行,代碼按預期工作,如我所說。 – 2011-05-12 14:46:11