jquery - 为什么 $ ("#RadioButtons:checked").val() 在 IE 中不起作用?

标签 jquery css-selectors

为什么 $("#RadioButtons:checked").val() - id 选择器 - 在 Internet Explorer 中不起作用,但 $("input:radio[name='RadioButtons ']:checked").val() - 名称选择器 - 是吗?

<input name="RadioButtons" id="RadioButtons" type="radio" value="1" checked>
<input name="RadioButtons" id="RadioButtons" type="radio" value="2">

<script>
  alert($("#RadioButtons:checked").val());
  alert($("input:radio[name='RadioButtons']:checked").val());
</script>

最佳答案

IE 在这个问题上更严格地遵循标准。两个元素不能具有相同的 ID。

关于jquery - 为什么 $ ("#RadioButtons:checked").val() 在 IE 中不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2924396/

相关文章:

CSS 子选择器 : can't select rows direct children of table, 不包括子表的子项

python - 如何修复操作系统错误: [WinError 6] The handle is invalid with Python and Selenium?

javascript - JQuery 轮播中的 ASP 转发器

javascript - 如何将子菜单定位到左侧

css - 如何指定出现两个相等类的 CSS 父级

css - 我可以将:nth-​​child()或:nth-​​of-type()与任意选择器结合使用吗?

javascript - Y 轴值与 Highcharts 中的蜡烛合并

javascript - 如何从输入中获取值并添加到href jquery

jquery - 将图像保存到 Json 文件

jquery - 使用 jQuery,如何确定浏览器是否原生支持 CSS 选择器 "input[type=text]"?