I have some radios in my page,and I want to do something when the checked radio changes,however the code does not work in IE:
$('input:radio').change(...);
And after googling,people suggest use the click instead. But it does not work.
This is the example code:
<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>
It also does not work in IE.
So I want to know what is going on?
Also I am afraid if it will retrigger the change event if I click a checked radio?
UPDATE:
I can not add comment,so I reply here.
I use IE8 and the link Furqan give me also does not work in IE8. I do not know why...
This code worked for me:
$(function(){
$('input:radio').change(function(){
alert('changed');
});
});