<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <script src="Scripts/jquery-1.4.1.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(function () {
            $("#btn1").click(function () {
                //取得radio所选的值的三种方式
                //alert($("input:radio:checked").val());
                //alert($(":radio:checked").val());
                //alert($(":radio[name=gender]:checked").val());
               
                //取得check所选的值用each遍历
                $(":checkbox:checked").each(function () {
                    alert($(this).val());
                });
            });
            $("#btn2").click(function () {
                //给radio赋值的三种方式
                //$("input:radio").val(["nan"]);
                //$(":radio").val(["nan"]);
                //$(":radio[name=gender]").val(["nan"]);
                
                //给check赋值的两种方式
                //$(":checkbox").val(["lanqiu", "zuqiu"]);
                $(":checkbox[value=lanqiu]").attr("checked",true);
            });
        });
    </script>
    
</head>
<body>
<input type="radio" name="gender" value="nv"/>女<br />
<input type="radio" name="gender" value="nan"/>男<br />
<input type="radio" name="gender" value="baomi"/>保密<br />
<input type="checkbox" value="lanqiu"/>篮球<br />
<input type="checkbox" value="zuqiu"/>足球<br />
<input type="checkbox" value="paiqiu"/>排球<br />
<input type="button" id="btn1" value="取值" />
<input type="button" id="btn2" value="设值" />
</body>
</html>