开发者

Why doesn't $("#RadioButtons:checked").val() work in IE?

开发者 https://www.devze.com 2023-01-01 21:21 出处:网络
Why doesn\'t $(\"#RadioButtons:checked\").val() - id selector - work in Internet Explorer but $(\"input:radio[name=\'RadioButtons\']:checked\").val() - name selector 开发者_如何学编程- does?

Why doesn't $("#RadioButtons:checked").val() - id selector - work in Internet Explorer but $("input:radio[name='RadioButtons']:checked").val() - name selector 开发者_如何学编程- does?

<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 more-closely follows the standard with regards to this issue. You can't have two elements with the same ID.

0

精彩评论

暂无评论...
验证码 换一张
取 消