
{"id":2496,"date":"2020-11-20T15:21:35","date_gmt":"2020-11-20T07:21:35","guid":{"rendered":"http:\/\/admin.evshou.com\/?p=2496"},"modified":"2020-11-23T11:31:43","modified_gmt":"2020-11-23T03:31:43","slug":"2020javaweb%e6%95%99%e7%a8%8b%e4%b9%8bjquery%e8%ae%be%e7%bd%ae%e5%b1%9e%e6%80%a7%e3%80%81%e8%8e%b7%e5%8f%96%e5%b1%9e%e6%80%a7","status":"publish","type":"post","link":"https:\/\/www.9713job.com\/?p=2496","title":{"rendered":"2020javaweb\u6559\u7a0b\u4e4bjQuery\u8bbe\u7f6e\u5c5e\u6027\u3001\u83b7\u53d6\u5c5e\u6027"},"content":{"rendered":"<h3>2020javaweb\u6559\u7a0b\u4e4bjQuery\u8bbe\u7f6e\u5c5e\u6027\u3001\u83b7\u53d6\u5c5e\u6027<\/h3>\n<p>\u83b7\u53d6<\/p>\n<p>DOM\uff1adocument.getElementById(&#8220;ele&#8221;);<br \/>\njquery\uff1a$(&#8220;#ele&#8221;)<\/p>\n<p>DOM:\u64cd\u4f5c\u7684\u662fJavaScript\u539f\u751f\u5bf9\u8c61<br \/>\njQuery\uff1a\u64cd\u4f5c\u7684\u662f\u81ea\u5df1\u5c01\u88c5\u7684\u5bf9\u8c61\uff0c\u5f53\u4e2d\u5305\u542b\u4e86\u539f\u751f\u5bf9\u8c61<br \/>\n<strong><span style=\"color: #ff0000;\">\u6ce8\u610f\uff1a\u53ea\u6709jQuery\u5bf9\u8c61\u624d\u53ef\u4ee5\u64cd\u4f5cjQuery\u51fd\u6570<\/span><\/strong><\/p>\n<p><strong>\u83b7\u5f97\u5185\u5bb9<\/strong><\/p>\n<pre>&lt;p&gt;\u8fd9\u662f\u7b2c\u4e00\u6bb5\u6587\u672c&lt;\/p&gt;\r\n&lt;p&gt;&lt;span&gt;\u8fd9\u662f\u7b2c\u4e8c\u6bb5\u6587\u672c&lt;\/span&gt;&lt;\/p&gt;\r\n&lt;p&gt;\u8fd9\u662f\u7b2c\u4e09\u6bb5\u6587\u672c&lt;\/p&gt;\r\n&lt;input type=\"password\" id=\"pwd\"&gt;&lt;br&gt;\r\n&lt;button id=\"btn1\"&gt;\u83b7\u53d6\u7b2c\u4e00\u6bb5\u6587\u672c\u5185\u5bb9&lt;\/button&gt;\r\n&lt;button id=\"btn2\"&gt;\u83b7\u53d6\u7b2c\u4e8c\u6bb5\u6587\u672chtml\u5185\u5bb9&lt;\/button&gt;\r\n&lt;button id=\"btn3\"&gt;\u83b7\u53d6\u5bc6\u7801\u6846\u5185\u5bb9&lt;\/button&gt;\r\n<!--more-->\r\n\r\n\r\n&lt;script&gt;\r\n    $(function(){\r\n        $(\"#btn1\").click(function () {\r\n            const s = $(\"p:first\").text();\r\n            console.log(s);\r\n        });\r\n        $(\"#btn2\").click(function () {\r\n            var s=$(\"p:eq(1)\").html();\r\n            console.log(s);\r\n        });\r\n        $(\"#btn3\").click(function () {\r\n            var value=$(\"input[type='password']\").val();\r\n            console.log(value);\r\n        })\r\n    })\r\n&lt;\/script&gt;<\/pre>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-2254\" src=\"\/wp-content\/uploads\/2020\/11\/20\/16.png\" alt=\"\" width=\"680\" \/><br \/>\n<img decoding=\"async\" class=\"alignnone size-full wp-image-2254\" src=\"\/wp-content\/uploads\/2020\/11\/20\/17.png\" alt=\"\" width=\"680\" \/><\/p>\n<p><strong>\u83b7\u53d6\u5c5e\u6027 attr\/prop<\/strong><\/p>\n<p>$(&#8220;ele&#8221;).attr(&#8220;action&#8221;);<\/p>\n<p><strong>\u8bbe\u7f6e\u5c5e\u6027 attr\/prop<\/strong><br \/>\n$(&#8220;ele&#8221;).attr(&#8220;checkbox&#8221;,true);<\/p>\n<p>\u5168\u9009\u3001\u53cd\u9009\u3001\u5168\u4e0d\u9009<\/p>\n<pre>&lt;input type=\"checkbox\" value=\"apple\"&gt;\u82f9\u679c\r\n&lt;input type=\"checkbox\" value=\"banana\"&gt;\u9999\u8549\r\n&lt;input type=\"checkbox\" value=\"pitaya\"&gt;\u706b\u9f99\u679c\r\n&lt;input type=\"checkbox\" value=\"strawberry\"&gt;\u8349\u8393 &lt;br&gt;\r\n&lt;button id=\"btn1\"&gt;\u5168\u9009&lt;\/button&gt;\r\n&lt;button id=\"btn2\"&gt;\u5168\u4e0d\u9009&lt;\/button&gt;\r\n&lt;button id=\"btn3\"&gt;\u53cd\u9009&lt;\/button&gt;\r\n&lt;script&gt;\r\n    $(function(){\r\n        $(\"#btn1\").click(function(){\/\/\u5168\u9009\r\n            var values=$(\"input[type='checkbox']\");\r\n            for(var i=0;i&lt;values.length;i++){\r\n                $(values[i]).prop(\"checked\",true);\r\n            }\r\n        });\r\n        $(\"#btn2\").click(function(){\/\/\u5168\u4e0d\u9009\r\n            var values=$(\"input[type='checkbox']\");\r\n            for(var i=0;i&lt;values.length;i++){\r\n                $(values[i]).prop(\"checked\",false);\r\n            }\r\n        });\r\n        $(\"#btn3\").click(function(){\/\/\u53cd\u9009\r\n            var values=$(\"input[type='checkbox']\");\r\n            for(var i=0;i&lt;values.length;i++){\r\n                if($(values[i]).prop(\"checked\")===true){\r\n                    $(values[i]).prop(\"checked\",false)\r\n                }else $(values[i]).prop(\"checked\",true)\r\n            }\r\n        });\r\n    })\r\n&lt;\/script&gt;<\/pre>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-2254\" src=\"\/wp-content\/uploads\/2020\/11\/20\/13.png\" alt=\"\" width=\"680\" \/><br \/>\n<img decoding=\"async\" class=\"alignnone size-full wp-image-2254\" src=\"\/wp-content\/uploads\/2020\/11\/20\/14.png\" alt=\"\" width=\"680\" \/><br \/>\n<img decoding=\"async\" class=\"alignnone size-full wp-image-2254\" src=\"\/wp-content\/uploads\/2020\/11\/20\/15.png\" alt=\"\" width=\"680\" \/><br \/>\n<img decoding=\"async\" class=\"alignnone size-full wp-image-2254\" src=\"\/wp-content\/uploads\/2020\/11\/20\/8.jpg\" alt=\"\" width=\"680\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>2020javaweb\u6559\u7a0b\u4e4bjQuery\u8bbe\u7f6e\u5c5e\u6027\u3001\u83b7\u53d6\u5c5e\u6027 \u83b7\u53d6 DOM\uff1adocument.getElemen [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-2496","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/www.9713job.com\/index.php?rest_route=\/wp\/v2\/posts\/2496","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.9713job.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.9713job.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.9713job.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.9713job.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2496"}],"version-history":[{"count":1,"href":"https:\/\/www.9713job.com\/index.php?rest_route=\/wp\/v2\/posts\/2496\/revisions"}],"predecessor-version":[{"id":2497,"href":"https:\/\/www.9713job.com\/index.php?rest_route=\/wp\/v2\/posts\/2496\/revisions\/2497"}],"wp:attachment":[{"href":"https:\/\/www.9713job.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2496"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.9713job.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2496"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.9713job.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2496"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}