jQuery 1.6.4 and RadioButtonList issue
jQuery 1.6.4 and RadioButtonList issue
从jQuery 1.4.4迁移到jQuery 1.6.4开始破坏我与radiobuttonlist相关的代码。
下面是复制奇怪行为的示例代码和步骤:
复制步骤:
1: Radio A已被选中。
2:选择电台B
3:在文本框中输入内容,然后tab out
您将看到:A被选中,B被选中。
那么从1.6.4到1.4.4到底是什么变化导致它崩溃的呢?
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script src="http://ajax.microsoft.com/ajax/jquery/jquery-1.6.4.min.js" type="text/javascript"></script>
<script type="text/javascript">
function txtchanged(tb) {
$(".rbl").find("input[type='radio']").each(function () {
alert($(this).val() + " " + $(this).attr("checked"));
});
}
</script>
</head>
<body>
<form id="form1" runat="server">
<asp:RadioButtonList ID="RadioButtonList1" runat="server" CssClass="rbl">
<asp:ListItem Text="A" Value="A" Selected="True" />
<asp:ListItem Text="B" Value="B" />
</asp:RadioButtonList>
<asp:TextBox ID="tb" runat="server" CssClass="tb" onblur="txtchanged(this)"></asp:TextBox>
</form>
</body>
</html>
Quote OP:
那么从1.6.4到1.4.4到底是什么变化导致它休息?
单选按钮checked
不是属性,它是属性。jQuery在1.6版中更新以纠正这个语义错误。
改变这一切…
.attr("checked")
这个… .prop("checked")
编辑:
关于OP关于为什么jQuery不向后兼容的评论:
1)这会增加代码的臃肿。
2) "向后兼容"实际上等于根本不解决这个问题。
请参阅本页阅读每个版本的jQuery发行说明。
.removeAttr('checked')
这个… .removeProp('checked')
相关文章:
- 运行Javascript更改RadioButtonList单击时的值
- 使RadioButtonList中选定的RadioButton不可单击但不禁用
- 如何使用RadioButtonList并使用Ember获取选定的值
- 如何让asp:Panel在没有AutoPostBack的情况下与asp:RadioButtonList正常工作
- Asp.net 使用 JQUERY 选择 RadioButtonList
- jQuery RadioButtonList 选中的值返回 “on”
- 当通过javascript设置值时,RadioButtonList不会在后续更改事件中触发
- 执行单击RadioButtonList ListItem
- RadioButtonList自定义验证器
- 使用客户端脚本处理RadioButtonList
- 如何为RadioButtonList的每个重复列设置不同的背景色
- 使用Javascript检查RadioButtonList的值
- 在不回发的情况下处理ajaxToolkit ModalPopupExtender中的RadioButtonList Se
- 使用javascript验证Gridview RadioButtonList
- 我们可以得到radiobuttonList.Items.Count在.aspx页面
- 在继承的ASP上使用Javascript清除选定项失败.净RadioButtonList
- 我的jQuery代码RadioButtonList有什么问题?
- RadioButtonList SelectedIndexChange即使在弹出表单
- RadioButtonList没有每次触发SelectedIndexChanged
- 在asp.net中恢复RadiobuttonList的先前状态