jquery属性操作

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <title></title>
        <script src="jquery-3.5.1.min.js" type="text/javascript" charset="utf-8"></script>
        <script type="text/javascript">
            $(document).ready(function() {
                var jqBtn = $("button");
                var jqIpt = $("input");
                var jqCkb = $("input:checkbox");

                jqBtn.click(function() {
                    jqIpt.attr("abc", "furong");
                    console.log(jqIpt.attr("abc"));

                    jqIpt.attr("class", "quange");

                    // jqCkb.attr("checked", true); // 一次性的
                    jqCkb.prop("checked", true);
                });
            });
        </script>
    </head>
    <body>
        <button type="button">button</button>
        <input type="" name="" id="" value="" />
        <input type="checkbox" name="" id="" value="" />
    </body>
</html>

(0)

相关推荐