我有兩個jQuery的版本測試下面的代碼:1.5.1和1.7.2
$(':radio').change(function(){alert(1)});
它工作在老的jQuery而不是新的。爲什麼我必須在新版本中使用.click()
?
瀏覽器:Chrome瀏覽器18
我有兩個jQuery的版本測試下面的代碼:1.5.1和1.7.2
$(':radio').change(function(){alert(1)});
它工作在老的jQuery而不是新的。爲什麼我必須在新版本中使用.click()
?
瀏覽器:Chrome瀏覽器18
它爲我的作品:
<input type="radio" name="foo" value="1" checked /> Radio 1 <br/>
<input type="radio" name="foo" value="2"/> Radio 2 <br/>
<script>
$(function() {
$(':radio').change(function() {
alert(this.value);
});
});
</script>
http://jsfiddle.net/alnitak/zsMAX/被設置爲使用jQuery 1.7.2
請創建jsfiddle.net測試案例,演示你的說法。 – Alnitak
它適合我 - http://jsfiddle.net/alnitak/zsMAX/ – Alnitak
你也試過'[type =「radio」]'?它應該是一個更快的選擇器,因爲它可以在QSA中使用 - > http://api.jquery.com/radio-selector/ – GNi33