{"id":13044,"date":"2023-11-29T10:17:56","date_gmt":"2023-11-29T02:17:56","guid":{"rendered":"https:\/\/wx.kaifamiao.info\/?p=13044"},"modified":"2023-11-29T10:18:10","modified_gmt":"2023-11-29T02:18:10","slug":"qian-duan-mian-shi-ti30-jq-zhong-zen-me-yang-bian","status":"publish","type":"post","link":"http:\/\/wx.kaifamiao.info\/index.php\/2023\/11\/29\/qian-duan-mian-shi-ti30-jq-zhong-zen-me-yang-bian\/","title":{"rendered":"\u524d\u7aef\u9762\u8bd5\u9898\uff1a30. Jq\u4e2d\u600e\u4e48\u6837\u7f16\u5199\u63d2\u4ef6\uff1f"},"content":{"rendered":"<p>\/\/\u7b2c\u4e00\u79cd\u662f\u7c7b\u7ea7\u522b\u7684\u63d2\u4ef6\u5f00\u53d1\uff1a<br \/>\n\/\/1.1\u6dfb\u52a0\u4e00\u4e2a\u65b0\u7684\u5168\u5c40\u51fd\u6570\u6dfb\u52a0\u4e00\u4e2a\u5168\u5c40\u51fd\u6570\uff0c\u6211\u4eec\u53ea\u9700\u5982\u4e0b\u5b9a\u4e49\uff1a<br \/>\njQuery. foo = function() {<br \/>\nalert(&#8216;This is a test\u3001 This is only a test. &#8216;)\uff1b}\uff1b<br \/>\n\/\/l. 2\u589e\u52a0\u591a\u4e2a\u5168\u5c40\u51fd\u6570\u6dfb\u52a0\u591a\u4e2a\u5168\u5c40\u51fd\u6570\uff0c\u53ef\u91c7\u7528\u5982\u4e0b\u5b9a\u4e49\uff1a<br \/>\njQuery. foo = function() {<br \/>\nalert(&#8216;This is a test\u3001 This is only a test.&#8217;)\uff1b}\uff1b<br \/>\nalert (* This function takes a parameter, which is + param +; \u8c03\u7528\u65f6\u548c\u4e00\u4e2a\u51fd\u6570<br \/>\n\u7684\u2014\u6837\u7684\uff1ajQuery.foo() \uff1b jQuery. bar ();\u6216\u8005<span class=\"katex math inline\">. foo() \uff1b<\/span>. bar (&#8216;bar&#8217;)\uff1b<br \/>\n\/\/l. 3 \u4f7f\u7528 jQuery. extend (object)\uff1b<br \/>\njQuery. extend({<br \/>\nfoo\uff1a function () {<br \/>\nalert(&#8216;This is a test. This is only a test.&#8217;)\uff1b<br \/>\n},<br \/>\nbar\uff1a function(param) {<br \/>\nalert(&#8216;This function takes a parameter, which is &quot;&#8217; + param+&#8217;&quot;.&#8217;<br \/>\n}<br \/>\n});<br \/>\n\/\/l. 4\u4f7f\u7528\u547d\u540d\u7a7a\u95f4<br \/>\n\/\/\u867d\u7136\u5728jQuery\u547d\u540d\u7a7a\u95f4\u4e2d\uff0c\u6211\u4eec\u7981\u6b62\u4f7f\u7528\u4e86\u5927\u91cf\u7684javaScript\u51fd\u6570\u540d\u548c\u53d8\u91cf\u540d\u3002<br \/>\n\/\/\u4f46\u662f\u4ecd\u7136\u4e0d\u53ef\u907f\u514d\u67d0\u4e9b\u51fd\u6570\u6216\u53d8\u91cf\u540d\u5c06\u4e8e\u5176\u4ed6jQuery\u63d2\u4ef6\u51b2\u7a81\uff0c\u56e0\u6b64\u6211\u4eec\u4e60\u60ef\u5c06\u4e00\u4e9b\u65b9\u6cd5<br \/>\n\/\/\u5c01\u88c5\u5230\u53e6\u4e00\u4e2a\u81ea\u5b9a\u4e49\u7684\u547d\u540d\u7a7a\u95f4\u3002<br \/>\njQuery. myPlugin = {<br \/>\nfoo\uff1a function() {<br \/>\nalert(&#8216;This is a test\u3001 This is only a test. &#8216;)\uff1b<br \/>\n},<br \/>\nbar: funct ion (param) {<br \/>\nalert(&#8216;This function takes a parameter, which is + param +<br \/>\n}<br \/>\n};<br \/>\n\/\/\u91c7\u7528\u547d\u540d\u7a7a\u95f4\u7684\u51fd\u6570\u4ecd\u7136\u662f\u5168\u5c40\u51fd\u6570\uff0c\u8c03\u7528\u65f6\u91c7\u7528\u7684\u65b9\u6cd5\uff1a<br \/>\n$. myPlugin. foo ()\uff1b<br \/>\n$. myPlugin. bar(&#8216; baz&#8217;);<br \/>\n\/\/\u901a\u8fc7\u8fd9\u4e2a\u6280\u5de7(\u4f7f\u7528\u72ec\u7acb\u7684\u63d2\u4ef6\u540d)\uff0c\u6211\u4eec\u53ef\u4ee5\u907f\u514d\u547d\u540d\u7a7a\u95f4\u5185\u51fd\u6570\u7684\u51b2\u7a81\u3002<br \/>\n\/\/\u7b2c\u4e8c\u79cd\u662f\u5bf9\u8c61\u7ea7\u522b\u7684\u63d2\u4ef6\u5f00\u53d1<br \/>\n\/\/\u5f62\u5f0f1\uff1a<br \/>\n(function($) {<br \/>\n$. fn. extend({<br \/>\npluginName : function(opt, callback){<br \/>\n\/\/ Our plugin implementation code goes here\u3001<br \/>\n}<br \/>\n})<br \/>\n}) (jQuery);<br \/>\n\/\/\u5f62\u5f0f2\uff1a<br \/>\n(function($) {<br \/>\n$. fn. pluginName = function() {<br \/>\n\/\/ Our plugin implementation code goes here\u3001<br \/>\n};<br \/>\n}) (jQuery);<br \/>\n\/\/\u5f62\u53c2\u662f$,\u51fd\u6570\u5b9a\u4e49\u5b8c\u6210\u4e4b\u540e\uff0c\u628ajQuery\u8fd9\u4e2a\u5b9e\u53c2\u4f20\u9012\u8fdb\u53bb.\u7acb\u5373\u8c03\u7528\u6267\u884c\u3002<br \/>\n\/\/\u8fd9\u6837\u7684\u597d\u5904\u662f\uff0c\u6211\u4eec\u5728\u5199jQuery\u63d2\u4ef6\u65f6\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528$\u8fd9\u4e2a\u522b\u540d,\u800c\u4e0d\u4f1a\u4e0eprototype\u5f15\u8d77\u51b2\u7a81<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\/\/\u7b2c\u4e00\u79cd\u662f\u7c7b\u7ea7\u522b\u7684\u63d2\u4ef6\u5f00\u53d1\uff1a \/\/1.1\u6dfb\u52a0\u4e00\u4e2a\u65b0\u7684\u5168\u5c40\u51fd\u6570\u6dfb\u52a0\u4e00\u4e2a\u5168\u5c40\u51fd\u6570\uff0c\u6211\u4eec\u53ea\u9700\u5982\u4e0b\u5b9a\u4e49\uff1a jQuer [&hellip;]<\/p>\n","protected":false},"author":8,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[103],"tags":[],"class_list":["post-13044","post","type-post","status-publish","format-standard","hentry","category-qianduan"],"_links":{"self":[{"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/posts\/13044","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/users\/8"}],"replies":[{"embeddable":true,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/comments?post=13044"}],"version-history":[{"count":1,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/posts\/13044\/revisions"}],"predecessor-version":[{"id":13045,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/posts\/13044\/revisions\/13045"}],"wp:attachment":[{"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/media?parent=13044"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/categories?post=13044"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/tags?post=13044"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}