为什么不$("#RadioButtons:checked").val()在IE中工作?

Ran*_*aps 2 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>
Run Code Online (Sandbox Code Playgroud)

Ric*_*ões 7

IE更严格地遵循该问题的标准.您不能拥有两个具有相同ID的元素.