jquery属性操作

  • A+
所属分类:Web前端
<!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>

jquery属性操作

jquery属性操作