我页面上有一些单选框,当选中的单选框发生变化时,我想要执行一些操作。然而在IE浏览器中这段代码不能工作:
$('input:radio').change(...);
在谷歌搜索之后,人们建议使用click代替。但它并没有起作用。
这是示例代码:
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>
<script type="text/javascript">
$('document').ready(
function(){
$('input:radio').click(
function(){
alert('changed');
}
);
}
);
</script>
</head>
<body>
<input type="radio" name="testGroup" id="test1" />test1<br/>
<input type="radio" name="testGroup" id="test2" />test2<br/>
<input type="radio" name="testGroup" id="test3" />test3</br>
</body>
</html>
它在IE中也不起作用。
所以我想知道发生了什么?
另外,如果我点击一个选中的单选按钮,它是否会重新触发更改事件,这让我担心?
更新:
我无法添加评论,所以我在这里回复。
我使用的是IE8,Furqan给我的链接在IE8中也不起作用。我不知道为什么......