It looks like this when used:
var _val = $("input[name='input1'][checked]").val();
It turns out that the value of _val is undefined. I thought it was written incorrectly at first. You can check it. No problem, the value can be obtained normally in IE6, 7, FF, Chrome, Opera, and Safari, but not in IE8. I was puzzled by the solution, and then I experimented:
var _val = $("input[name='input1']").eq(0).val();
The value can be obtained, indicating that the problem may occur in the checked attribute of the radio , experiment again:
var _val = document. getElementsByName("input1")[0].getAttribute("checked"); The value of
is true or false in IE6, 7, FF, Chrome, Opera, Safari, but in IE8 Is empty,
in IE8:
var _val = document.getElementsByName("input1")[0].checked;
can be set to true or false. I don’t know if this is a bug in IE8 or if Microsoft has other intentions?
Final use:
var _val = $(":radio[name='input1'][checked]").val();
This works fine on various browsers. It is estimated that the testers of jquery1.3.2 The testing of IE8 is not comprehensive enough, I hope the next version can solve this problem.