{"id":228,"date":"2023-02-23T06:37:11","date_gmt":"2023-02-22T22:37:11","guid":{"rendered":"https:\/\/www.appblog.cn\/?p=228"},"modified":"2023-04-30T15:22:52","modified_gmt":"2023-04-30T07:22:52","slug":"jquery-usage-notes","status":"publish","type":"post","link":"https:\/\/www.appblog.cn\/index.php\/2023\/02\/23\/jquery-usage-notes\/","title":{"rendered":"jQuery\u4f7f\u7528\u7b14\u8bb0"},"content":{"rendered":"<h3>\u83b7\u53d6div\u7684\u5bbd\u5ea6<\/h3>\n<p>\u5f53\u83b7\u53d6div\u7684\u5bbd\u5ea6\u4e3a\u201c100%\u201d\uff0c\u60f3\u83b7\u53d6\u5176\u5177\u4f53\u7684\u50cf\u7d20\u503cpx\u600e\u4e48\u529e<\/p>\n<p>\u5e73\u5e38\u7684\u65f6\u5019\u83b7\u53d6div\u7684\u5bbd\u5ea6\u65b9\u6cd5\uff1a<\/p>\n<p><!-- more --><\/p>\n<pre><code class=\"language-javascript\">document.getElementById(&quot;div_id&quot;).style.width;<\/code><\/pre>\n<p>\u4f46\u662f\u5f53div\u7684\u5bbd\u5ea6\u6837\u5f0f\u8bbe\u7f6e\u4e3a\u767e\u5206\u53f7\u5236\u7684\u65f6\u5019\u9700\u8981\u901a\u8fc7clientWidth\u6765\u83b7\u53d6\u5176\u5bbd\u5ea6\u3002\u5982\u4e0b<\/p>\n<pre><code class=\"language-javascript\">document.getElementById(&quot;div_id&quot;).clientWidth;<\/code><\/pre>\n<h3>\u83b7\u53d6\u53ca\u8bbe\u7f6eForm\u8868\u5355Ratio\u9009\u4e2d\u503c<\/h3>\n<pre><code class=\"language-html\">&lt;div class=&quot;col-sm-6&quot;&gt;\n    &lt;div class=&quot;radio&quot;&gt;\n        &lt;label&gt;\n            &lt;input type=&quot;radio&quot; name=&quot;server_operate&quot; value=&quot;server_init&quot; class=&quot;minimal server_operate&quot; checked \/&gt;&nbsp;\u521d\u59cb\u5316&nbsp;&nbsp;\n        &lt;\/label&gt;\n    &lt;\/div&gt;\n    &lt;div class=&quot;radio&quot;&gt;\n        &lt;label&gt;\n            &lt;input type=&quot;radio&quot; name=&quot;server_operate&quot; value=&quot;server_start&quot; class=&quot;minimal server_operate&quot; \/&gt;&nbsp;\u542f\u52a8&nbsp;&nbsp;\n        &lt;\/label&gt;\n    &lt;\/div&gt;\n    &lt;div class=&quot;radio&quot;&gt;\n        &lt;label&gt;\n            &lt;input type=&quot;radio&quot; name=&quot;server_operate&quot; value=&quot;server_stop&quot; class=&quot;minimal server_operate&quot;  \/&gt;&nbsp;\u505c\u6b62&nbsp;&nbsp;\n        &lt;\/label&gt;\n    &lt;\/div&gt;\n    &lt;div class=&quot;radio&quot;&gt;\n        &lt;label&gt;\n            &lt;input type=&quot;radio&quot; name=&quot;server_operate&quot; value=&quot;server_restart&quot; class=&quot;minimal server_operate&quot;  \/&gt;&nbsp;\u91cd\u542f&nbsp;&nbsp;\n        &lt;\/label&gt;\n    &lt;\/div&gt;\n    &lt;div class=&quot;radio&quot;&gt;\n        &lt;label&gt;\n            &lt;input type=&quot;radio&quot; name=&quot;server_operate&quot; value=&quot;database_reset&quot; class=&quot;minimal server_operate&quot;  \/&gt;&nbsp;\u91cd\u7f6e\u6570\u636e\u5e93\uff08\u614e\u91cd\uff09&nbsp;&nbsp;\n        &lt;\/label&gt;\n    &lt;\/div&gt;\n&lt;\/div&gt;<\/code><\/pre>\n<p>\u83b7\u53d6Form\u8868\u5355Ratio\u9009\u4e2d\u503c\uff1a<\/p>\n<pre><code class=\"language-javascript\">var operate = $(&quot;input:radio[name=\\&quot;server_operate\\&quot;]:checked&quot;).val();<\/code><\/pre>\n<p>\u9009\u4e2d\u503c\u4e3aserver_init\u7684Radio\uff1a<\/p>\n<pre><code class=\"language-javascript\">$(&quot;input[name=&#039;radioName&#039;][value=server_init]&quot;).attr(&quot;checked&quot;, true);<\/code><\/pre>\n<h3>\u83b7\u53d6Meta\u503c<\/h3>\n<pre><code class=\"language-html\">&lt;meta name=&quot;csrf-token&quot; content=&quot;G3CZ92cHXlKx24q8EDcRkYyD4wevXJ9Zp6GMPt2h&quot; \/&gt;\n\n\/\/jQuery\u83b7\u53d6Meta\u503c\n$(&quot;meta[name=\\&quot;csrf-token\\&quot;]&quot;).attr(&quot;content&quot;)<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u83b7\u53d6div\u7684\u5bbd\u5ea6 \u5f53\u83b7\u53d6div\u7684\u5bbd\u5ea6\u4e3a\u201c100%\u201d\uff0c\u60f3\u83b7\u53d6\u5176\u5177\u4f53\u7684\u50cf\u7d20\u503cpx\u600e\u4e48\u529e \u5e73\u5e38\u7684\u65f6\u5019\u83b7\u53d6div\u7684\u5bbd\u5ea6 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[33],"tags":[82],"class_list":["post-228","post","type-post","status-publish","format-standard","hentry","category-frontend-basic","tag-jquery"],"_links":{"self":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/228","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/comments?post=228"}],"version-history":[{"count":0,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/228\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/media?parent=228"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/categories?post=228"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/tags?post=228"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}