{"id":1188,"date":"2018-05-30T14:58:24","date_gmt":"2018-05-30T06:58:24","guid":{"rendered":"http:\/\/www.yusian.com\/blog\/?p=1188"},"modified":"2020-12-01T12:46:26","modified_gmt":"2020-12-01T04:46:26","slug":"jquery%e6%8f%92%e4%bb%b6%e5%bc%80%e5%8f%91%e4%b9%8b%e5%ae%9e%e4%be%8b%e6%8f%92%e4%bb%b6%e6%a8%a1%e6%9d%bf%e8%af%b4%e6%98%8e","status":"publish","type":"post","link":"https:\/\/www.yusian.com\/blog\/javascript\/2018\/05\/30\/1458241188.html","title":{"rendered":"jQuery\u63d2\u4ef6\u5f00\u53d1\u4e4b\u5b9e\u4f8b\u63d2\u4ef6\u6a21\u677f\u8bf4\u660e"},"content":{"rendered":"<p>1\u3001\u6240\u8c13\u7684jQuery\u63d2\u4ef6\u4e8b\u5b9e\u4e0a\u5c31\u662fjQuery\u7684\u6269\u5c55\u65b9\u6cd5\uff0c\u5206\u4e3a\u4e24\u79cd\uff1a\u7c7b\u65b9\u6cd5\u4e0e\u5b9e\u4f8b\u65b9\u6cd5\uff1b\u5bf9\u4e8e\u6709\u8fc7\u9762\u5411\u5bf9\u8c61\u7f16\u7a0b\u7684\u4eba\u6765\u8bb2\u662f\u4e0d\u662f\u975e\u5e38\u719f\u6089\uff1f\uff01<\/p>\n<p>2\u3001\u7c7b\u65b9\u6cd5\u6269\u5c55\u5f88\u7b80\u5355\uff0c\u5373\u6269\u5c55\u7c7b\u4f3c$.post()\u8fd9\u79cd\u65b9\u6cd5\uff0c\u76f4\u63a5\u4f7f\u7528$\u8c03\u7528\uff0c\u90a3\u4e48\u6269\u5c55\u65b9\u6cd5\u53ef\u4ee5\u76f4\u63a5\u5199\u6210$.xxx = function(){}\u5373\u53ef\uff1b\u7c7b\u65b9\u6cd5\u5168\u5c40\u8c03\u7528\uff1b<\/p>\n<p>3\u3001\u5b9e\u4f8b\u65b9\u6cd5\uff0c\u5373\u5fc5\u987b\u662f$(&#8216;someone&#8217;).xxxx()\u5f62\u5f0f\u7684\u8c03\u7528\uff0c\u8fd9\u79cd\u65b9\u6cd5\u5982\u4f55\u6269\u5c55\u5462\uff1f\u56e0\u4e3a\u8fd8\u4e0d\u77e5\u9053\u6269\u5c55\u7ed9\u54ea\u4e2a\u5b9e\u4f8b\uff0c\u6240\u4ee5\u5728\u6269\u5c55\u65b9\u6cd5\u662f\u62ff\u4e0d\u5230\u8be5\u5b9e\u4f8b\u3002\u5176\u5b9ejQuery\u6709\u4e2a\u5c5e\u6027\u53ebfn\uff0c\u6240\u6709\u7684\u5b9e\u4f8b\u65b9\u6cd5\u90fd\u6302\u5728\u8be5\u5c5e\u6027\u4e0b\u9762\uff0c\u5b98\u65b9\u7ed9\u51fa\u4e86\u6269\u5c55\u5b9e\u4f8b\u65b9\u6cd5\u7684\u6807\u51c6\u6a21\u677f\uff0c\u53ef\u80fd\u4e00\u773c\u770b\u8fc7\u6765\u6709\u70b9\u8499\uff0c\u4e0b\u9762\u6211\u901a\u8fc7\u51e0\u4e2a\u7248\u672c\u7684\u6f14\u53d8\u6765\u89e3\u91ca\u8be5\u201c\u6807\u51c6\u6a21\u677f\u201d\u662f\u5982\u4f55\u5f97\u6765\u7684\uff1a<\/p>\n<pre lang=\"javascript\" line=\"1\">\/\/ 1.0\u3001\u6700\u7b80\u5355\u7248\u672c\r\n$.fn.xxx = function(){\r\n    \/\/ \u5b9e\u73b0\u4ee3\u7801...\r\n}\r\n\/\/ 1.1\u3001\u517c\u987e\u53c2\u6570\u4e0e\u9009\u62e9\u5668\u96c6\u5408\r\n$.fn.xxx = function(options){\r\n    this.each(function(){\r\n        \/\/ \u5b9e\u73b0\u4ee3\u7801...\r\n    });\r\n}\r\n\r\n\/\/ 1.2\u3001\u589e\u52a0\u521d\u59cb\u53c2\u6570\u6216\u9ed8\u8ba4\u503c\r\n$.fn.xxx = function(options){\r\n    let defaults = {\r\n\r\n    }\r\n    options = $.extend(defaults, options);\r\n    this.each(function(){\r\n\r\n    });\r\n}\r\n\r\n\/\/ 1.3\u3001\u66f4\u52a0\u4e25\u8c28\u5199\u6cd5\uff0c\u4f7f\u7528\u533f\u540d\u51fd\u6570\u5305\u88f9\u5e76\u6267\u884c\r\n(function(){\r\n    $.fn.xxx = function(options){\r\n        let defaults = {\r\n    \r\n        }\r\n        options = $.extend(defaults, options);\r\n        this.each(function(){\r\n    \r\n        });\r\n    }\r\n})();\r\n\r\n\/\/ 1.4\u3001\u5b8c\u5584\u4f18\u5316jQuery\u5bf9\u8c61\u672c\u8eab\u7684\u5f71\u54cd\r\n(function($){\r\n    $.fn.xxx = function(options){\r\n        let defaults = {\r\n    \r\n        }\r\n        options = $.extend(defaults, options);\r\n        this.each(function(){\r\n    \r\n        });\r\n    }\r\n})(jQuery);<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>1\u3001\u6240\u8c13\u7684jQuery\u63d2\u4ef6\u4e8b\u5b9e\u4e0a\u5c31\u662fjQuery\u7684\u6269\u5c55\u65b9\u6cd5\uff0c\u5206\u4e3a\u4e24\u79cd\uff1a\u7c7b\u65b9\u6cd5\u4e0e\u5b9e\u4f8b\u65b9\u6cd5\uff1b\u5bf9\u4e8e\u6709\u8fc7\u9762\u5411\u5bf9\u8c61\u7f16\u7a0b\u7684\u4eba\u6765\u8bb2\u662f\u4e0d\u662f\u975e\u5e38\u719f\u6089\uff1f\uff01 2\u3001\u7c7b\u65b9\u6cd5\u6269\u5c55\u5f88\u7b80\u5355\uff0c\u5373\u6269\u5c55\u7c7b\u4f3c$.post()\u8fd9\u79cd\u65b9\u6cd5\uff0c\u76f4\u63a5\u4f7f\u7528$\u8c03\u7528\uff0c\u90a3\u4e48\u6269\u5c55\u65b9\u6cd5\u53ef\u4ee5\u76f4\u63a5\u5199\u6210$.xxx = function(){}\u5373\u53ef\uff1b\u7c7b\u65b9\u6cd5\u5168\u5c40\u8c03\u7528\uff1b 3\u3001\u5b9e\u4f8b\u65b9\u6cd5\uff0c\u5373\u5fc5\u987b\u662f$(&#8216;someone&#8217;).xxxx()\u5f62\u5f0f\u7684\u8c03\u7528\uff0c\u8fd9\u79cd\u65b9\u6cd5\u5982\u4f55\u6269\u5c55\u5462\uff1f\u56e0\u4e3a\u8fd8\u4e0d\u77e5\u9053\u6269\u5c55\u7ed9\u54ea\u4e2a\u5b9e\u4f8b\uff0c\u6240\u4ee5\u5728\u6269\u5c55\u65b9\u6cd5\u662f\u62ff\u4e0d\u5230\u8be5\u5b9e\u4f8b\u3002\u5176\u5b9ejQuery\u6709\u4e2a\u5c5e\u6027\u53ebfn\uff0c\u6240\u6709\u7684\u5b9e\u4f8b\u65b9\u6cd5\u90fd\u6302\u5728\u8be5\u5c5e\u6027\u4e0b\u9762\uff0c\u5b98\u65b9\u7ed9\u51fa\u4e86\u6269\u5c55\u5b9e\u4f8b\u65b9\u6cd5\u7684\u6807\u51c6\u6a21\u677f\uff0c\u53ef\u80fd\u4e00\u773c\u770b\u8fc7\u6765\u6709\u70b9\u8499\uff0c\u4e0b\u9762\u6211\u901a\u8fc7\u51e0\u4e2a\u7248\u672c\u7684\u6f14\u53d8\u6765\u89e3\u91ca\u8be5\u201c\u6807\u51c6\u6a21\u677f\u201d\u662f\u5982\u4f55\u5f97\u6765\u7684\uff1a \/\/ 1.0\u3001\u6700\u7b80\u5355\u7248\u672c $.fn.xxx = function(){ \/\/ \u5b9e\u73b0\u4ee3\u7801&#8230; } \/\/ 1.1\u3001\u517c\u987e\u53c2\u6570\u4e0e\u9009\u62e9\u5668\u96c6\u5408 $.fn.xxx = function(options){ this.each(function(){ \/\/ \u5b9e\u73b0\u4ee3\u7801&#8230; }); } \/\/ 1.2\u3001\u589e\u52a0\u521d\u59cb\u53c2\u6570\u6216\u9ed8\u8ba4\u503c $.fn.xxx = function(options){ let defaults = { } options = $.extend(defaults, options); this.each(function(){ }); } \/\/ 1.3\u3001\u66f4\u52a0\u4e25\u8c28\u5199\u6cd5\uff0c\u4f7f\u7528\u533f\u540d\u51fd\u6570\u5305\u88f9\u5e76\u6267\u884c (function(){ $.fn.xxx = function(options){ let defaults = { } options = $.extend(defaults, options); [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[28],"tags":[53,73,83],"class_list":["post-1188","post","type-post","status-publish","format-standard","hentry","category-javascript","tag-javascript","tag-jquery","tag-83"],"_links":{"self":[{"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/posts\/1188","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/comments?post=1188"}],"version-history":[{"count":0,"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/posts\/1188\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/media?parent=1188"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/categories?post=1188"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/tags?post=1188"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}