Why wont jQuery change() wont work with radio buttons in asp.net WebForms?
jQuery change() wont work with my radio buttons in asp.net WebForms.
Heres a jsFiddle link on the code I'm trying to use in my webform application.
jsFiddle
I'm using jQuery 1.4.1
Anyone knowing the problem?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.4.1.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
radiogroup = $('#radio').children('input:radio');
$(radiogroup).change(function () {
if ($(this).val() == 'on') {
alert($(this).val());
$('.timeLimit').show();
}
if ($(this).val() == 'off') {
alert($(this).val());
$('.timeLimit').hide();
}
});
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div id="radio" class="cell ms-formbody">
<input type="radio" value="on" id="radio1" name="radio" /><label for="radio1"开发者_JAVA技巧>On</label>
<input type="radio" value="off" id="radio2" name="radio" checked="checked" /><label for="radio2">Off</label>
</div>
</form>
</body>
</html>
I've spent more than 3 hours trying to find the reason for my problem, and now desperate for help. :(
The problem was solved by using jQuery 1.6.2 instead of 1.4.1
精彩评论