2019.10.27.png


代码实例:

<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8" />
    <title></title>
    <script src="http://blog.fqidc.cn/jquery-3.4.1.min.js" type="text/javascript" charset="utf-8">     </script>
</head>
<body>
    <form action="#" method="post" id="form">
        账号:<input type="text"/><br /><br />
        密码:<input type="password"/><br /><br /> 
        性别:<input type="radio"/>男 <input type="radio"/>男♂<br /><br />
        爱好:<input type="checkbox"/>?
            <input type="checkbox"/>??
            <input type="checkbox"/>???
            <input type="checkbox"/>????
            <input type="checkbox"/>?????<br /><br />
        <input type="submit" value="提交" />
    </form>
    <table border="1px">
        <tr>
            <th id="arr"><a href="#">全选/全不选</a></th>
            <td>姓名</td>
            <td>年龄</td>
            <td>大小</td>
        </tr>
        <tr>
            <td><input type="checkbox"/></td>
            <td>姓名</td>
            <td>年龄</td>
            <td>大小</td>
        </tr>
        <tr>
            <td><input type="checkbox"/></td>
            <td>姓名</td>
            <td>年龄</td>
            <td>大小</td>
        </tr>
        <tr>
            <td><input type="checkbox"/></td>
            <td>姓名</td>
            <td>年龄</td>
            <td>大小</td>
        </tr>
        <tr>
            <td><input type="checkbox"/></td>
            <td>姓名</td>
            <td>年龄</td>
            <td>大小</td>
        </tr>
    </table>
    <script type="text/javascript">
        $("#arr").click(function(){
            if($("td :checkbox").attr("checked")==="checked"){
                $("td :checkbox").removeAttr("checked")
            }else{
                $("td :checkbox").attr("checked","true");
            }                
        });
    
    
        //获取和赋值     val()获取     val("123")赋值
        $("#form :text").val("12233");
        //获取默认选中属性
        $("#form :radio:eq(1)").attr("checked","true");
    </script>
</body>

</html>

##


20191027111335.jpg


属性操作
20191027113956.jpg