JQUERY如何取单选框的值?
 <tr>
<td>人员性别:</td>
<td><input type = "radio" value = "1"  name = "PersonSex_Add" id="PersonSex_Add1"  />男
    <input type = "radio" value = "0"  name = "PersonSex_Add" id="PersonSex_Add2"  />女</td>
</tr>

例如:我选择了“男”,请问:JQUERY如何取单选框选中的值?

解决方案 »

  1.   

    jquery的版本不同,获取也有出入,如果你是1.3后的jq版本,那么如下
    $("input[name='PersonSex_Add']:checked").val()
    老版本jq的话,name前加个@符号
      

  2.   

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <script type="text/javascript" src="jquery-1.3.2.min.js"></script>
        <script type="text/javascript">
            $(document).ready(function(){
                $("#Select1 option").each(function(){
                    alert($(this).attr("selected"))
                })
            })
        </script>
    </head>
    <body>
        <select id="Select1">
            <option>1</option>
            <option selected="selected">男</option>
            <option selected="selected">女</option>
        </select>
    </body>
    </html>
      

  3.   


    v=document.getElementById("PersonSex_Add1").checked?男:女;
      

  4.   


    v=document.getElementById("PersonSex_Add1").checked?"男":"女";
      

  5.   


    //获取单选按钮的值
    $("input[name='PersonSex_Add']").val(); //获取选中的值
    $("input[name='PersonSex_Add'][checked]").val()