- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
从 jQuery 1.4.4 迁移到 jquery 1.6.4 开始破坏我与 radiobuttonlist 相关的代码。
这是复制奇怪行为的示例代码和步骤:
重现步骤:
1:电台A已经被选中。
2:选择单选B
3:在文本框中输入内容并跳出。
您将看到:A is checked 和 B is checked 警报。
那么从 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>
最佳答案
引用 OP:
So what exactly changed from 1.6.4 to 1.4.4 that is causing it to break?
单选按钮 checked
不是一个属性,它是一个属性。 jQuery 在 1.6 版中进行了更新以更正此语义错误。
改变这个...
.attr("checked")
对于这个...
.prop("checked")
编辑:
关于 OP 关于为什么 jQuery 不向后兼容的评论:
1) 它会增加代码的膨胀。
2) “向后兼容”实际上等同于根本不解决这个问题。
See this page to read the release notes on every version of jQuery .
也改变这个...
.removeAttr('checked')
对于这个...
.removeProp('checked')
关于javascript - jQuery 1.6.4 和 RadioButtonList 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7745387/
出于好奇,任何人都知道内部实现的细节 ListControl.SelectedIndex = (int) 对比 ListControl.SelectedValue = .ToString() 我在使
首先,repeater with in a repeater可以用吗?如果是,我将如何在以下场景中使用嵌套中继器。
我创建了一个包含 2 个选项的选项列表:是和否,如下所示 radioButtonList($model,'active', array(1=>'Yes', 0=>'No'), array('separ
我有一个 ASP RadioButtonList,我想在客户端处理它。 该网页包含一个带有单选按钮组和关联的 GridView 的表单。当用户选择单选按钮之一时,我想隐藏或显示 GridView 上的
我有一个RadioButtonList,有两个选项:完整和部分。默认选择已满。 Full Partial 我还有一个 jquery 函数,它会导致某些元素在选择“部分”时隐藏,并
如何向 RadioButtonList 添加超链接? 我尝试了以下方法,但它仍然呈现为纯文本。 A"> B"> 我知道以下工作,但我想使用 RadioButtonList 而不是
我有一个单选按钮列表,其中包含更新搜索功能的 selectedindexchanged 事件。其中一项在 aspx 中指定,其他项是附加的数据绑定(bind)项。无论我将什么设置为默认值,该项目都不会
我正在 ASP.net 中创建一个注册 Web 表单,但在客户端发送空字符串,因为我选择了一个选项,其背后的原因是什么以及如何获得非空字符串。 这是我的 RadioButtonList 代码。
当我们在文本框中输入时,我需要使单选按钮列表可过滤。意思是如果我输入 M 然后应该显示 Music & Movie radio 。我想用 JS 或 jquery 来避免回发。我对他们两个都不太了解。
我想要一个单选按钮列表,您可以在其中选择值 null。 是这样的: '> RW R None 非常感谢,文森特 最佳答案 单选按钮
我有一个 DataList,它显示一些带有 RadioButtonList 的帖子,其中包含从 1 到 5 的 5 个选择,但是当我尝试获取 theRadioButtonList 的选定值时,它抛出空
我在 Web 表单上有一个 RadioButtonList 和一个提交按钮。当我单击具有空 RadioButtonList 值的提交按钮时,即没有从 RadioButtonList 中选择任何内容,我
我正在系统后端创建一个单选按钮列表。有什么方法可以让我以随机顺序显示项目吗? 我的代码: c# RadioButtonList1.Items.Add(New ListItem(rsQuestio
我正在寻找处理在 ASP.net RadioButtonList(后面的 C# 代码)上选择的索引更改的最佳方法。我有 3 个列表项。对于第一个,我希望它在页面上显示一个隐藏的 asp:textbox
基本上,我只想要 RadioButtonList 上没有单选按钮,我将对 rbl 进行编码,以便所选项目具有不同的背景颜色并使其看起来更专业,我希望能够摆脱单选按钮本身外观......如果你知道任何方
我有一个单选按钮列表,我需要在一些值之间添加标签。 我知道以下内容行不通,但这是我想在 .net 中执行的操作的最佳示例。 Regular
无论我在单选按钮列表上设置什么,它仍然呈现一个无序的垂直列表。 最佳答案 如果您碰巧正在使用 Sitefinity(就像我一样)
aspx 文件: ' DataSource='' Da
当我单击 ASP.NET 页面上的按钮控件时,我的单选按钮列表在回发后未选中地返回。
我似乎无法将 RadioButtonList 居中放置在面板中。它似乎总是有道理的。不管我怎么努力。 我目前的代码是:
我是一名优秀的程序员,十分优秀!