{"id":4701,"date":"2016-01-06T14:52:35","date_gmt":"2016-01-06T06:52:35","guid":{"rendered":"https:\/\/sdeno.com\/?p=4701"},"modified":"2016-01-06T14:52:35","modified_gmt":"2016-01-06T06:52:35","slug":"jquery%e4%b8%8emootools%e5%ba%93%e7%9a%84%e4%b8%80%e4%ba%9b%e6%af%94%e5%af%b9","status":"publish","type":"post","link":"https:\/\/sdeno.com\/?p=4701","title":{"rendered":"jQuery\u4e0eMooTools\u5e93\u7684\u4e00\u4e9b\u6bd4\u5bf9"},"content":{"rendered":"<p>\u6211\u4e0a\u5927\u5b66\u90a3\u4f1a\u513f\u4ece\u4e8b\u7684\u9879\u76ee\u7528\u7684\u662fjQuery\uff0c\u6bd5\u4e1a\u540e\u5de5\u4f5c\u6240\u4ece\u4e8b\u7684\u9879\u76ee\u7528\u7684\u662fMooTools\u3002\u5f88\u5e78\u8fd0\u77ed\u671f\u5185\u6709\u673a\u4f1a\u63a5\u89e6\u4e24\u6b3e\u4e0d\u540c\u8bbe\u8ba1\u98ce\u683c\u7684\u4f18\u79c0\u7684JavaScript\u5e93\u3002\u4eca\u5929\u5c31\u6211\u81ea\u5df1\u7684\u4e00\u4e9b\u8ba4\u8bc6\u6bd4\u5bf9\u4e0b\u8fd9\u4e24\u4e2aJS\u6846\u67b6\uff0c\u66f4\u591a\u7684\u662f\u5e0c\u671b\u5927\u5bb6\u80fd\u591f\u5bf9MooTools\u8fd9\u4e2aJS\u6846\u67b6\u6709\u66f4\u591a\u7684\u8ba4\u8bc6\u3002\u6bd5\u7adf\uff0c\u5927\u591a\u6570\u4ece\u4e8bweb\u524d\u7aef\u7684\u4eba\u5bf9\u4e0a\u624b\u5bb9\u6613\u7684jQuery\u66f4\u719f\u6089\u4e9b\u3002<\/p>\n<h3>\u4e00\u3001API\u8bbe\u8ba1<\/h3>\n<p>\u5c31API\u7684\u8bbe\u8ba1\u4e0a\u6765\u8bb2\uff0c\u65e0\u8bba\u662fMooTools\uff0c\u6216\u662f\u5176\u4ed6\u7c7b\u4f3cYUI\u7684JS\u6846\u67b6\u90fd\u6bd4jQuery\u7565\u900a\u4e00\u7b79\u3002<\/p>\n<p id=\"jmTest\">API\u662f\u4ec0\u4e48\uff1f\u6839\u636e\u67d0\u4e9b\u8457\u4f5c\u7684\u56de\u7b54\uff0cAPI\u662f\u5bf9\u6240\u9700\u77e5\u8bc6\u7684\u62bd\u8c61\uff0c\u5b83\u5c06\u7cfb\u7edf\u7684\u590d\u6742\u6027\u9690\u85cf\u8d77\u6765\u3002\u4f8b\u5982\u6c7d\u8f66\u7684\u65b9\u5411\u76d8\uff0c\u7535\u89c6\u673a\u4e0a\u7684\u6309\u94ae\u3002\u4e00\u4e2aAPI\u8bbe\u8ba1\u7684\u597d\u574f\u53ef\u4ee5\u4ece\u4e0b\u9762\u51e0\u4e2a\u65b9\u9762\u8bc4\u4f30\uff1a\u53ef\u7406\u89e3\u6027\u3001\u4e00\u81f4\u6027\u3001\u9884\u89c1\u6027\u3001\u7b80\u5355\u6027\u3001\u4fdd\u62a4\u6027\u3002<\/p>\n<p><strong>\u53ef\u7406\u89e3\u6027<\/strong><\/p>\n<div>\u4f8b\u5982<code>selector<\/code>(\u9009\u62e9\u5668)\u3002\u968f\u4fbf\u4e3e\u4e2a\u9009\u62e9\u5668\u7684\u4f8b\u5b50(jQuery)\uff1a<\/div>\n<div class=\"zxx_code\">\n<pre style=\"color: #0000ff;\">$(\"#jQuery div\")<\/pre>\n<\/div>\n<p>\u9009\u62e9\u5668\u7684\u5199\u6cd5\u662f\u4e0eCSS\u7684\u9009\u62e9\u5668\u662f\u4e00\u8109\u76f8\u627f\u7684\u3002\u56e0\u6b64\u5bf9\u4e8e\u5f88\u591a\u5199\u9875\u9762\u7684\u4eba\u6765\u8bb2\uff0c\u53ef\u4ee5\u5f88\u8f7b\u677e\u5730\u4f7f\u7528jQuery\u627e\u5230\u81ea\u5df1\u60f3\u8981\u7684\u90a3\u6839\u8471\u3002jQuery\u540e\u6765\u7684\u7248\u672c\u4e4b\u6240\u4ee5\u628aXPath\u5e72\u6389\uff0c\u6216\u8bb8\u5c31\u662f\u56e0\u4e3a\u7406\u89e3\u6027\u4e0a\u7684\u95ee\u9898\u5427\u3002\u5f53\u7136\uff0cMooTools\u4e5f\u662f\u652f\u6301CSS\u9009\u62e9\u5668\u7684\uff0c\u53ea\u4e0d\u8fc7\uff0c\u5176\u4e0d\u662f\u4f7f\u7528\u4e00\u4e2a\u7f8e\u5143\u7b26\u53f7$\uff0c\u800c\u662f\u4e24\u4e2a$$\uff0c\u8c8c\u4f3c\u662f\u5b66\u4e60prototype\u6846\u67b6\uff0c\u8fd4\u56de\u7684\u662f\u6570\u7ec4\u3002<\/p>\n<div class=\"zxx_code\">\n<pre style=\"color: #0000ff;\">$$(\"#MooTools div\")<\/pre>\n<\/div>\n<p>\u5982\u679cMooTools\u53ea\u8d70\u5230\u8fd9\u4e00\u6b65\uff0c\u6211\u89c9\u5f97\u8fd8\u597d\uff0c\u8c8c\u4f3c\u8ddfjQuery\u7684\u53ef\u7406\u89e3\u6027\u6253\u4e2a\u5c0f\u5e73\u624b\u3002\u53ea\u53ef\u60dc\uff0cMooTools\u8fd8\u6709\u4e00\u4e2a\u5355\u4e2a\u7f8e\u5143\u7b26\u53f7$\u7684\u9009\u62e9\u5668\uff0c\u5176\u4e2d\u53c2\u6570\u53ea\u80fd\u662f\u5143\u7d20\u7684id\uff0c\u4f8b\u5982\uff1a<\/p>\n<div class=\"zxx_code\">\n<pre style=\"color: #0000ff;\">$(\"MooTools\")<\/pre>\n<\/div>\n<p>\u8fd9\u73a9\u610f\uff0c\u9009\u62e9\u7684\u8c8c\u4f3c\u662f\u6709\u4e2aMooTools\u5143\u7d20\u6269\u5c55\u65b9\u6cd5\u7684\u5bf9\u8c61\u3002\u5982\u679c\u4e0d\u5b58\u5728\uff0c\u5e94\u7528\u5143\u7d20\u65b9\u6cd5\u7684\u65f6\u5019(eg: addClass)\u5219\u4f1a\u62a5\u9519\u3002<\/p>\n<p>\u4e5f\u5c31\u662f\u8bf4MooTools\u9009\u62e9\u5143\u7d20\uff0c\u6839\u636e\u7528\u6cd5\u7684\u4e0d\u540c\uff0c\u6709\u65f6\u5019\u8fd4\u56de\u7684\u53ef\u80fd\u5c31\u662f\u6570\u7ec4\uff0c\u6709\u65f6\u5019\u53c8\u662f\u5143\u7d20\u5bf9\u8c61\u3002\u8fd9\u96be\u514d\u8ba9\u5bf9JS\u719f\u6089\uff0c\u5bf9CSS\u8f83\u719f\u6089\u7684\u4eba\u5458\u6709\u4e86\u7406\u89e3\u548c\u4f7f\u7528\u4e0a\u7684\u56f0\u96be\u4e86\u3002\u4e0d\u8fc7\u8fd9\u4e0d\u80fd\u602aMooTools\uff0c\u8bbe\u8ba1\u67b6\u6784\u4e0a\u7684\u4e0d\u540c\u5bfc\u81f4MooTools\u6709\u65f6\u5019\u9700\u8981\u8fd4\u56de\u5143\u7d20\u5bf9\u8c61\uff0c\u800c\u4e0d\u662f\u5143\u7d20\u5bf9\u8c61\u6570\u7ec4\u3002<\/p>\n<p>\u56e0\u6b64\uff0c\u4ece\u7406\u89e3\u6027\u4e0a\u6765\u8bf4\uff0cMooTools\u900a\u4e8ejQuery\u4e86\u3002<\/p>\n<p><strong>\u4e00\u81f4\u6027<\/strong><\/p>\n<div>JS\u6846\u67b6\u7684\u4e00\u81f4\u6027\u7684\u4e3b\u8981\u4f53\u73b0\u4e4b\u4e00\u5c31\u662f\u94fe\u5f0f\u8c03\u7528\uff0c\u4f8b\u5982(jQuery)\uff1a<\/div>\n<div class=\"zxx_code\">\n<pre style=\"color: #0000ff;\">$(\"#jQuery\").css(\"color\", \"red\").height(200);<\/pre>\n<\/div>\n<p>MooTools\u4e5f\u662f\u652f\u6301\u94fe\u5f0f\u8c03\u7528\u7684\uff0c\u4f8b\u5982(MooTools)\uff1a<\/p>\n<div class=\"zxx_code\">\n<pre style=\"color: #0000ff;\">$$(\"#MooTools\").setStyle(\"color\", \"red\").setStyle(\"height\", 200);<\/pre>\n<\/div>\n<p>\u5728\u94fe\u5f0f\u8c03\u7528\u4e0a\uff0cjQuery\u548cMooTools\u57fa\u672c\u4e0a\u90fd\u662f\u5f88OK\u7684\u3002<\/p>\n<p>\u4f46\u662f\uff0c\u5728\u5176\u4ed6\u65b9\u9762\u7684\u4e00\u81f4\u6027\u4e0a\uff0cMooTools\u4f3c\u4e4e\u53c8\u843d\u4e8e\u4e0b\u98ce\u4e86\u3002jQuery\u8fd9\u4e2a\u6846\u67b6\u771f\u7684\u5f88\u795e\u5947\uff0c\u4e00\u4e2a<code>$<\/code>\u7b26\u53f7\u5c31\u53ef\u4ee5\u4ece\u5e7f\u5dde\u8d70\u5230\u5317\u4eac\uff0c\u771f\u53ef\u8c13\u4e07\u80fd\u5bc6\u5319\u554a\u3002<br \/>\n\u9996\u5148\u9009\u62e9\u5668\uff0c\u4f8b\u5982<code>$(\"#jQuery\")<\/code>\u80af\u5b9a\u662f<code>$<\/code>\u7b26\u53f7\uff0c\u7136\u540e\uff0c\u5176\u76f8\u5173\u7684\u5176\u4ed6\u4e9b\u65b9\u6cd5\uff0c\u4f8b\u5982\u63d2\u4ef6\u673a\u5236\u4e4b<code>$.fn.extend(object)<\/code>\uff0c\u6216\u8005\u662fAjax\u8bf7\u6c42<code>$.ajax([options])<\/code>\uff0c\u53c8\u6216\u662f\u6d4f\u89c8\u5668\u68c0\u6d4b\uff0c\u6570\u7ec4\u5bf9\u8c61\u65b9\u6cd5\u7b49\u7b49\u7b49\u7b49\u90fd\u662f<code>$<\/code>\u7b26\u53f7\u6a2a\u884c\u7684\u3002<\/p>\n<p>\u4f46\u662f\uff0cMooTools\u6851\u4e2d<code>$<\/code>\u7b26\u53f7\u51fa\u73b0\u5728\u9009\u62e9\u5668\uff0c\u8ba9\u4eba\u96be\u61c2\u7684<code>$A<\/code>,\u00a0<code>$E<\/code>\uff0c\u4ee5\u53ca\u4e00\u4e9b\u516c\u5171\u65b9\u6cd5\u547d\u540d\u4e0a\uff0c\u5176\u4f59\u65f6\u5019\u90fd\u56de\u5bb6\u7761\u89c9\u89c9\u4e86\u3002<br \/>\n\u7ee7\u627f\u9700\u8981<code>new Class()<\/code>\u6784\u9020\uff0cAjax\u8bf7\u6c42\u4e3a<code>new Request([options])<\/code>\uff0c\u7136\u540e\u6d4f\u89c8\u5668\u68c0\u6d4b\u53c8\u662f\u4ee5<code>Browser<\/code>\u5f00\u5934\u3002\u6570\u7ec4\uff0c\u5b57\u7b26\u4e32\u7b49\u65b9\u6cd5\u53c8\u90fd\u662f\u5f53\u524d\u5bf9\u8c61\u672c\u8eab\u6253\u5934\uff0c\u5982<code>myString.trim()<\/code>\u3002\u6beb\u65e0\u4e00\u81f4\u6027\u53ef\u8a00\uff0c\u663e\u7136\uff0c\u8fd9\u4e2a\u7684\u5b66\u4e60\u6210\u672c\u548c\u4f7f\u7528\u96be\u5ea6\u8981\u6bd4jQuery\u5927\u591a\u4e86\u3002<\/p>\n<p><strong>\u9884\u89c1\u6027<\/strong><\/p>\n<div>\u597d\u7684API\u5e94\u8be5\u8003\u8651\u5230\u7528\u6237\u7684\u65e0\u7eea\u6027\u9009\u62e9(<code>selective cluelessness<\/code>)\u4ee5\u53ca\u9884\u89c1\u672a\u6765\u53ef\u80fd\u53d1\u751f\u7684\u4e00\u4e9b\u4e8b\u60c5\u3002<\/div>\n<p>\u4e0d\u77e5\u662fJohn Resig(jQuery \u4e4b\u7236)\u786e\u5b9e\u60f3\u7684\u5f88\u8fdc\uff0c\u8fd8\u662f\u56e0\u4e3a\u5e78\u8fd0\uff0c\u6216\u662f\u53ea\u56e0\u4e3aJohn\u662f\u4e2a\u5929\u624d\uff0cjQuery\u7684\u8bbe\u8ba1\u8ba9\u5176\u4f3c\u4e4e\u4e0d\u4f1a\u4e0e\u672a\u6765\u53d1\u751f\u51b2\u7a81\u3002<br \/>\n\u4e3e\u4e2a\u8001\u5230\u5543\u4e0d\u52a8\u7684\u4f8b\u5b50\uff0c\u8fc7\u6ee4\u5b57\u7b26\u4e32\u7684\u524d\u540e\u7a7a\u683c\u3002jQuery\u7684\u505a\u6cd5\u662f\uff1a<\/p>\n<div class=\"zxx_code\">\n<pre style=\"color: #0000ff;\">$.trim(myString);<\/pre>\n<\/div>\n<p>MooTools\u505a\u6cd5\u662f\uff1a<\/p>\n<div class=\"zxx_code\">\n<pre style=\"color: #0000ff;\">myString.trim();<\/pre>\n<\/div>\n<p>\u4e4d\u4e00\u770b\uff0c\u4f3c\u4e4eMooTools\u6846\u67b6\u7684\u505a\u6cd5\u66f4\u7b26\u5408\u6211\u4eec\u7684\u7406\u89e3 \u2192 \u5b57\u7b26\u4e32\u5bf9\u8c61\u6709\u4e2a<code>trim<\/code>\u65b9\u6cd5\uff0c\u8fd4\u56de\u8fc7\u6ee4\u524d\u540e\u7a7a\u683c\u7684\u5b57\u7b26\u4e32\u65b9\u6cd5\u3002However\uff0c\u968f\u7740\u65f6\u95f4\u62d6\u79fb\uff0c\u6709\u4e9b\u4e8b\u60c5\u5c31\u5f00\u59cb\u53d1\u751f\u53d8\u6570\u4e86\u3002<\/p>\n<p>\u5728ECMAScript 5(ES5)\u4e2d\uff0c\u5b57\u7b26\u4e32\u662f\u5185\u7f6e<code>trim<\/code>\u65b9\u6cd5\u7684\u3002\u6211\u4eec\u53ef\u4ee5\u505a\u4e2a\u5c0f\u5c0f\u7684\u6d4b\u8bd5\uff0c\u5982\u4e0b\u4ee3\u7801\uff1a<\/p>\n<div class=\"zxx_code\">\n<pre style=\"color: #0000ff;\">alert((\" foo \").trim());<\/pre>\n<\/div>\n<p>\u60a8\u53ef\u4ee5\u72e0\u72e0\u5730\u70b9\u51fb\u8fd9\u91cc\uff1a<a class=\"a_link\" style=\"color: #ff3300;\" href=\"http:\/\/www.zhangxinxu.com\/study\/201109\/es5-trim-test.html\" target=\"_blank\">ES5 \u5185\u7f6etrim\u65b9\u6cd5\u6d4b\u8bd5<\/a><\/p>\n<p>\u4f8b\u5982\uff0c\u5728\u6211\u7684FireFox 6\u6d4f\u89c8\u5668\u4e0b\uff0c\u5f39\u51fa\u7684\u5c31\u662f<code>foo<\/code>\uff0c\u5982\u4e0b\u622a\u56fe\uff1a<br \/>\n<figure class=\"mdx-lazyload-container\" style=\"max-width:278px\"><div style=\"padding-top:67.26618705036%\"><\/div><div class=\"mdx-img-loading-sp mdui-valign\"><div><div class=\"mdui-spinner\"><\/div><\/div><\/div><img width=\"278\" height=\"187\" class=\"lazyload\" title=\"FireFox 6 \u5f39\u51fafoo\" src=\"data:image\/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==\" data-src=\"http:\/\/image.zhangxinxu.com\/image\/blog\/201109\/2011-09-27_111730.png\" alt=\"FireFox 6 \u5f39\u51fafoo\"><\/figure><\/p>\n<p>\u5bf9\u4e8e\u4e00\u4e9b\u6709\u5386\u53f2\u4ef7\u503c\u7684\u6d4f\u89c8\u5668\uff0c\u5c31\u4e0d\u652f\u6301\uff0c\u4f8b\u5982IE7\u6a21\u5f0f\u4e0b\uff1a<br \/>\n<figure class=\"mdx-lazyload-container\" style=\"max-width:457px\"><div style=\"padding-top:46.17067833698%\"><\/div><div class=\"mdx-img-loading-sp mdui-valign\"><div><div class=\"mdui-spinner\"><\/div><\/div><\/div><img width=\"457\" height=\"211\" class=\"lazyload\" title=\"jQuery\u4e0eMooTools\u5e93\u7684\u4e00\u4e9b\u6bd4\u5bf9\" src=\"data:image\/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==\" data-src=\"http:\/\/image.zhangxinxu.com\/image\/blog\/201109\/2011-09-27_112537.png\" alt=\"http:\/\/image.zhangxinxu.com\/image\/blog\/201109\/2011-09-27_112537.png\"><\/figure><\/p>\n<p>\u540c\u6837\u7c7b\u4f3c\u7684\u5c31\u662f\u57fa\u4e8eFunction\u6269\u5c55\u7684<code>bind<\/code>\u65b9\u6cd5\uff0cMooTools\u4e2d\u6709\uff0c\u4f46\u662f\uff0cES5\u4e2d\u4e5f\u5185\u7f6e\u4e86\u3002\u53ea\u662f\uff0c\u6bd4\u8f83\u5e78\u8fd0\u7684\u662f\uff0c\u65e0\u8bba\u662f\u5b57\u7b26\u4e32<code>trim<\/code>\u65b9\u6cd5\uff0c\u6216\u662f\u51fd\u6570<code>bind<\/code>\u65b9\u6cd5\uff0c\u867d\u7136\u540d\u79f0\u51b2\u7a81\u4e86\uff0c\u4f46\u662f\uff0c\u6240\u5b9e\u73b0\u7684\u529f\u80fd\u786e\u662f\u4e00\u6837\u7684\uff0c\u56e0\u6b64\uff0c\u4e5f\u7b97\u4e0d\u4e0a\u51b2\u7a81\u4e86\u3002\u4f46\u662f\uff0c\u4e07\u4e00\u54ea\u5929\u9047\u5230\u4e2a\u4e0d\u5e78\uff0cMooTools\u4e2d\u7684\u67d0\u4e2a\u65b9\u6cd5\u4e0eES5\u4e2d\u7684\u65b9\u6cd5\u540c\u540d\u4f46\u4e0d\u540c\u529f\u80fd\uff0c\u7136\u540e\uff0c\u53ea\u80fd\u8001\u6cea\u7eb5\u6a2a\u4e86\uff01<\/p>\n<p>\u518d\u4e3e\u4e2a\u9884\u89c1\u6027\u7684\u4f8b\u5b50\uff0c\u9009\u62e9\u5668\u9009\u62e9\u5bf9\u8c61\u4ee5\u53caDOM\u5bf9\u8c61\u3002jQuery\u5bf9jQuery\u5bf9\u8c61\u548c\u539f\u751fdom\u5bf9\u8c61\u8fdb\u884c\u4e86\u5206\u79bb\uff0c\u4f8b\u5982\uff1a<\/p>\n<div class=\"zxx_code\">\n<pre style=\"color: #0000ff;\">$(\"input\").bind(\"focus\", function() {\r\n    alert(this.value);\t    <span style=\"color: green;\">\/\/ dom\u5bf9\u8c61<\/span>\r\n    alert($(this).val());   <span style=\"color: green;\">\/\/ jQuery\u5305\u88c5\u5668\u5bf9\u8c61<\/span>\r\n});<\/pre>\n<\/div>\n<p>\u4f46\u662f\uff0c\u5728MooTools\u4e2d\uff0c\u4e00\u4e9b\u65b9\u6cd5\u662f\u5728\u539f\u751fDOM\u4e0a\u6269\u5c55\u7684\uff0cMooTools\u5143\u7d20\u5bf9\u8c61\u548c\u539f\u751fdom\u662f\u5408\u4f53\u7684\uff0c\u4f8b\u5982\uff1a<\/p>\n<div class=\"zxx_code\">\n<pre style=\"color: #0000ff;\">$$(\"input\").addEvent(\"focus\", function() {\r\n    alert(this.value);           <span style=\"color: green;\">\/\/ dom\u5bf9\u8c61<\/span>\r\n    alert(this.get(\"value\"));    <span style=\"color: green;\">\/\/ \u6269\u5c55\u540e\u7684dom\u5bf9\u8c61<\/span>\r\n});<\/pre>\n<\/div>\n<p>\u201c\u5408\u4f53\u201d\u7684\u95ee\u9898\u5728\u4e8e\u968f\u7740\u6d4f\u89c8\u5668\u4ee5\u53ca\u4e00\u4e9b\u89c4\u8303\u7684\u53d1\u5c55\uff0c\u539f\u751fdom\u53ef\u80fd\u4f1a\u652f\u6301\u5176\u4ed6\u7684\u4e00\u4e9b\u65b9\u6cd5\uff0c\u8fd9\u4e9b\u65b9\u6cd5\u6709\u53ef\u80fd\u5c31\u548cMooTools\u63d2\u4ef6\u4e2dDOM\u6269\u5c55\u65b9\u6cd5\u51b2\u7a81\u3002\u597d\u5728MooTools\u7684\u65b9\u6cd5\u547d\u540d\u5c5e\u4e8e\u5bf9\u79f0\u547d\u540d\uff0c\u4e14\u8bed\u4e49\u660e\u663e\uff0c\u8fd9\u79cd\u8bbe\u8ba1\u53ef\u4ee5\u6709\u6548\u907f\u514d\u4e0e\u539f\u751fdom\u65b9\u6cd5\u7684\u51b2\u7a81\u3002\u4f46\u662f\uff0c\u4e8b\u60c5\u6ca1\u6709\u8fd9\u7b80\u5355\u2026\u2026\u4e0b\u9762\u4f60\u53ef\u4ee5\u770b\u5230MooTools\u4e2dDOM\u5143\u7d20\u65b9\u6cd5\u7684\u8bbe\u8ba1\u7684\u4e00\u4e9b\u95ee\u9898\uff08\u5f53\u7136\uff0c\u4e0d\u53ef\u5426\u8ba4\uff0c\u8fd9\u79cd\u8bbe\u8ba1\u4f7f\u7528\u4e0a\u76f8\u5bf9\u7075\u6d3b\u4e9b\uff09\u3002<\/p>\n<p><strong>\u7b80\u5355\u6027<\/strong><\/p>\n<div>jQuery\u4e4b\u6240\u4ee5\u8ba9\u5f00\u53d1\u8005\u604b\u604b\u4e0d\u820d\uff0c\u539f\u56e0\u4e4b\u4e00\u5c31\u662f\u5176\u7b80\u5355\u3002jQuery\u7684\u53e3\u53f7\u5c31\u662f\u201dwrite less, do more.\u201d<\/div>\n<p>\u62ffdom-style\u7684API\u4e3e\u4f8b\uff0cMooTools, YUI\u7b49\u6846\u67b6\u91c7\u7528\u7684\u662f\u4f20\u7edf\u5bf9\u79f0\u547d\u540d\u7684\u65b9\u5f0f(prop\u4e3aproperty\u5c5e\u6027\u7f29\u5199)\uff1a<\/p>\n<div class=\"zxx_code\">\n<pre style=\"color: #0000ff;\">el.setStyle(prop, val);  \r\nel.getStyle(prop);  \r\nel.setStyles({ propA: valA, propB: valB });  \r\nel.getStyles(propA, propB);\t  <span style=\"color: green;\">\/\/ MooTools\u652f\u6301, \u8fd4\u56de\u662f\u4e2a\u540d-\u503c\u5bf9\u8c61<\/span><\/pre>\n<\/div>\n<p>\u5728jQuery\u91cc\uff0c\u4e00\u4e2aCSS\u5c31\u628a\u6240\u6709\u74f7\u5668\u6d3b\u90fd\u63fd\u4e86\uff1a<\/p>\n<div class=\"zxx_code\">\n<pre style=\"color: #0000ff;\">el.css(prop);    <span style=\"color: green;\">\/\/ \u8868\u793a getStyle<\/span>  \r\nel.css(prop, val);    <span style=\"color: green;\">\/\/ \u8868\u793a setStyle<\/span>  \r\nel.css({ propA: valA, propB: valB });    <span style=\"color: green;\">\/\/ \u8868\u793a setStyles <\/span>  \r\nel.css(prop, func);    <span style=\"color: green;\">\/\/ func \u662f\u4e00\u4e2a\u8fd4\u56de val \u503c\u7684\u51fd\u6570<\/span><\/pre>\n<\/div>\n<p>\u867d\u7136\u53c2\u6570\u7c7b\u4f3c\uff0c\u4f46\u662fjQuery\u53ea\u8981\u8bb0\u4e00\u4e2a\u540d\u5b57\uff0c\u800cMooTools\u5374\u8981N\u4e2a\uff0c\u4e14\u540d\u5b57\u4e5f\u6bd4\u8f83\u957f\uff08\u5fc5\u987b\u5b8c\u6574\u4e14\u957f\uff0c\u5426\u5219\u6613\u51fa\u95ee\u9898\uff09\u3002\u8fd9\u4e5f\u662f\u4e3a\u4ec0\u4e48jQuery\u66f4\u5bb9\u6613\u4e0a\u624b\u7684\u539f\u56e0\u3002\u800c\u4e14\uff0cjQuery\u66f4\u8fd1\u4e00\u6b65\uff0c\u8fd8\u652f\u6301<code>func<\/code>\u56de\u8c03\uff0c\u4e14\u53c2\u6570\u53ef\u4ee5<code>map<\/code>,\u00a0<code>val<\/code>\u53ef\u4ee5\u662f\u51fd\u6570\uff0c\u6697\u85cf\u591a\u591asurprise\u554a\u3002<\/p>\n<p>\u663e\u7136\uff0c\u7b80\u5355\u6027\u8fd9\u5757\u53c8\u662fjQuery\u597d\u4e00\u4e9b\u3002<br \/>\n\u8fd9\u91cc\uff0c\u6211\u8fd8\u60f3\u8bf4\u70b9\u5176\u4ed6\u76f8\u5173\u7684\u4e1c\u897f\u3002jQuery\u6846\u67b6\u7684\u77ed\u547d\u540d\u8bbe\u8ba1\u786e\u5b9e\u597d\uff0c\u4e8e\u662f\u6211\u5c31\u60f3\u5bf9MooTools\u7684\u5143\u7d20\u65b9\u6cd5\u8fdb\u884c\u6269\u5c55\uff0c\u4f7f\u7b49\u540c\u4e8ejQuery\u7684\u547d\u540d\u4e66\u5199\u65b9\u5f0f\uff0c\u4e00\u662f\u7701\u4e9b\u4ee3\u7801\uff0c\u4e8c\u662f\u65b9\u4fbf\u719f\u6089jQuery\u7684\u65b0\u5458\u5de5\u4e0a\u624b\uff0c\u62ff\u8fd8\u662f\u4e0a\u9762dom-style\u7684\u4f8b\u5b50\uff0cMooTools\u5982\u4e0b\u6269\u5c55\u5904\u7406\uff1a<\/p>\n<div class=\"zxx_code\">\n<pre style=\"color: #0000ff;\">Element.implement({\r\n    <span style=\"color: green;\">\/\/\u5c06mootools\u9ed8\u8ba4\u7684setStyle\u4ee5\u53casetStyles\u65b9\u6cd5\u8f6c\u5316\u4e3a\u4e0ejQuery\u7c7b\u4f3c\u7684css()\u5f62\u5f0f<\/span>\r\n    css: function(key, value) {\r\n        if ($type(key) == 'object') {\r\n            for (var p in key) this.css(p, key[p]);\r\n            return this;\r\n        }\r\n        if(!$chk(value)){\r\n            return this.<span style=\"color: brown;\">getStyle<\/span>(key);\r\n        }\r\n        this.<span style=\"color: brown;\">setStyle<\/span>(key, value);\r\n        return this;\r\n    }\r\n});<\/pre>\n<\/div>\n<p>\u4e8e\u662f\uff0cMooTools\u4e5f\u652f\u6301CSS\u65b9\u6cd5\uff0c\u4f8b\u5982\u53ef\u4ee5\u76f4\u63a5<code>$(\"mootools\").css({ border: \"1px solid #ddd\" });<\/code>\u3002\u6069\uff0c\u770b\u4e0a\u53bb\u4e0d\u9519\uff0c\u786e\u5b9e\uff0c\u4e0a\u9762\u7684\u6269\u5c55\u5728\u76ee\u524d\u5404\u4e2a\u6d4f\u89c8\u5668\u4e2d\u662f\u6ca1\u6709\u4efb\u4f55\u95ee\u9898\u7684\u3002\u4e8e\u662f\uff0c\u521d\u5c1d\u5230\u4e86\u751c\u5934\uff0c\u6211\u4eec\u5c31\u60f3\u6a21\u62df\u5176\u4ed6jQuery\u5305\u88c5\u5668\u65b9\u6cd5\u7684\u6269\u5c55\uff0c\u4f8b\u5982<code>width\/height<\/code>\u65b9\u6cd5\uff0c\u5982\u4e0b(<code>width<\/code>\u4e3e\u4f8b)\uff1a<\/p>\n<div class=\"zxx_code\">\n<pre style=\"color: #0000ff;\">Element.implement({\r\n    width: function (val) {\r\n        if ($chk(val)) {\r\n            return this.setStyle(\"width\", val);\r\n        } else {\r\n            return this.getWidth();    \r\n        }\r\n    }\r\n});<\/pre>\n<\/div>\n<p>\u770b\u4e0a\u53bb\u4e0d\u9519\uff0c\u4e0d\u662f\u5417\uff1f\u4f46\u662f\uff0c\u4eba\u751f\u4e0d\u5982\u610f\u4e8b\u516b\u4e5d\uff0c\u4e0a\u9762MooTools\u6846\u67b6\u5bf9dom\u8fdb\u884c\u7684<code>width<\/code>\u65b9\u6cd5\u6269\u5c55\u662f\u6709\u95ee\u9898\u7684\u3002\u6211\u4eec\u90fd\u77e5\u9053\uff0c<code>&lt;img&gt;<\/code>\u5143\u7d20\u662f\u6709<code>width<\/code>\u5c5e\u6027\u7684\u3002\u6b63\u5982\u4e0a\u9762\u63d0\u5230\u7684\uff0cMooTools\u6846\u67b6\u7684\u5143\u7d20\u65b9\u6cd5\u662f\u5728DOM\u4e0a\u9762\u76f4\u63a5\u201c\u5408\u4f53\u201d\u6269\u5c55\u7684\u3002\u4e8e\u662f\u4e4e\uff0c\u5bf9\u4e8e\u56fe\u7247\u800c\u8a00\uff0c\u4f7f\u7528\u4e0a\u9762\u6269\u5c55\u7684<code>width<\/code>\u65b9\u6cd5\u662f\u4f1a\u55dd\u5c41\u7684\u2014\u2014\u539f\u751f\u5c5e\u6027\u4e0e\u6269\u5c55\u65b9\u6cd5\u51b2\u7a81\u3002<\/p>\n<div class=\"zxx_code\">\n<pre style=\"color: #0000ff;\">alert($(\"image\").width()); <span style=\"color: red;\">\/\/\u62a5\u9519\uff0c\u663e\u793a$(\"image\").width\u4e0d\u662ffunction<\/span><\/pre>\n<\/div>\n<p>\u7531\u6b64\u53c8\u8fdb\u4e00\u6b65\u8bc1\u5b9e\u4e86jQuery\u5728API\u8bbe\u8ba1\u4e0a\u66f4\u80fd\u907f\u514d\u4e00\u4e9b\u5f53\u4e0b\u6216\u672a\u6765\u6f5c\u5728\u7684\u51b2\u7a81\uff0c\u66f4\u5177\u8fdc\u89c1\u6027\u3002<\/p>\n<p><strong>\u4fdd\u62a4\u6027<\/strong><\/p>\n<div>jQuery\u6709\u4e2a\u591a\u5e93\u5171\u5b58\u673a\u5236\uff0c\u53ef\u4ee5\u6709\u6548\u5730\u4fdd\u62a4\u5176\u4ed6\u6846\u67b6\u90fd\u5728\u4e89\u593a\u7684$\u7b26\u53f7\uff0c\u6709\u6548\u907f\u514d\u4e86\u4e00\u4e9b\u517c\u5bb9\u6027\u7684\u95ee\u9898\u3002<\/div>\n<div class=\"zxx_code\">\n<pre style=\"color: #0000ff;\">jQuery.noConflict();\r\n(function($) { \r\n  $(function() {\r\n    <span style=\"color: green;\">\/\/ \u4f7f\u7528 $ \u4f5c\u4e3a jQuery \u522b\u540d\u7684\u4ee3\u7801<\/span>\r\n  });\r\n})(jQuery);\r\n<span style=\"color: green;\">\/\/ \u5176\u4ed6\u7528 $ \u4f5c\u4e3a\u522b\u540d\u7684\u5e93\u7684\u4ee3\u7801<\/span><\/pre>\n<\/div>\n<p>\u800cMooTools\u4e2d\u4f3c\u4e4e\u5e76\u65e0\u8fd9\u6837\u7684\u673a\u5236\u3002<\/p>\n<p>\u603b\u7ed3\uff1a\u5c31API\u8bbe\u8ba1\u8fd9\u70b9\u6765\u8bb2\uff0cjQuery\u51e0\u4e4e\u4ece\u5404\u4e2a\u65b9\u9762\u90fd\u5f3a\u4e8eMooTools\uff0c\u8fd9\u4e5f\u662fjQuery\u5927\u884c\u5176\u9053\u7684\u4e3b\u8981\u539f\u56e0\u3002<\/p>\n<h3>\u4e8c\u3001\u6027\u80fd<\/h3>\n<p><strong>\u9009\u62e9\u5668\u6027\u80fd<\/strong><\/p>\n<p>MooTools\u6846\u67b6\u5b98\u65b9\u9875\u9762\u63d0\u4f9b\u4e86\u9009\u62e9\u5668\u6027\u80fd\u6d4b\u8bd5\u9875\u9762\uff1a<a style=\"color: #34538b;\" href=\"http:\/\/mootools.net\/slickspeed\/\" target=\"_blank\">speed\/validity selectors test for frameworks<\/a><\/p>\n<p>\u70b9\u51fb\u53f3\u4e0a\u89d2\u7684\u201dstart tests\u201d\u6309\u94ae\uff0c\u4e00\u6bb5\u65f6\u95f4\u540e\u5c31\u53ef\u4ee5\u770b\u5230\u5404\u4e2a\u6846\u67b6\u4e0b\u5404\u4e2a\u9009\u62e9\u5668\u6d4b\u8bd5\u7ed3\u679c\u4e86\u3002\u4e0b\u8868\u4e3a\u6211\u8054\u7cfb\u6d4b\u8bd5\u4e09\u6b21\u540e\u7684\u7ed3\u679c\u8bb0\u5f55\uff0c\u53ef\u4ee5\u770b\u5230\uff0cjQuery\u9009\u62e9\u5668\u7684\u603b\u4f53\u6027\u80fd\u7565\u6bd4prototype\u4f4e\uff0c\u6bd4MooTools\u8981\u5f3a\u3002\u4f46\u662f\uff0c\u5728\u6211\u4eec\u5b9e\u9645\u4e9b\u9875\u9762\u505a\u4ea4\u4e92\u7684\u65f6\u5019\uff0c\u5176\u4e2d\u9009\u62e9\u5668\u7684\u5dee\u5f02\u57fa\u672c\u4e0a\u53ef\u4ee5\u5ffd\u7565\u4e0d\u8bb0\uff08YUI\u5728<code>:nth-child<\/code>\u9009\u62e9\u5668\u4e0a\u7684\u7cdf\u7cd5\u8868\u73b0\u80af\u5b9a\u8981\u63d0\u9632\u7684\uff09\u3002<\/p>\n<table class=\"params_table\" border=\"0\" width=\"100%\" cellspacing=\"1\" cellpadding=\"0\">\n<tbody>\n<tr>\n<th scope=\"col\"><\/th>\n<th scope=\"col\">MooTools 1.2<\/th>\n<th scope=\"col\">MooTools 1.3.1<\/th>\n<th scope=\"col\">JQuery 1.5.1<\/th>\n<th scope=\"col\">Prototype 1.7<\/th>\n<th scope=\"col\">YUI 2.8.2 Selector<\/th>\n<th scope=\"col\">Dojo 1.5<\/th>\n<\/tr>\n<tr>\n<th scope=\"row\">\u7b2c\u4e00\u6b21\u6d4b\u8bd5\u603b\u65f6\u95f4<\/th>\n<td>75<\/td>\n<td>67<\/td>\n<td>37<\/td>\n<td>34<\/td>\n<td>685<\/td>\n<td>49<\/td>\n<\/tr>\n<tr>\n<th scope=\"row\">\u7b2c\u4e8c\u6b21\u6d4b\u8bd5\u603b\u65f6\u95f4<\/th>\n<td>66<\/td>\n<td>56<\/td>\n<td>28<\/td>\n<td>26<\/td>\n<td>668<\/td>\n<td>48<\/td>\n<\/tr>\n<tr>\n<th scope=\"row\">\u7b2c\u4e09\u6b21\u6d4b\u8bd5\u603b\u65f6\u95f4<\/th>\n<td>67<\/td>\n<td>55<\/td>\n<td>30<\/td>\n<td>30<\/td>\n<td>663<\/td>\n<td>43<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<figure class=\"mdx-lazyload-container\" style=\"max-width:514px\"><div style=\"padding-top:52.140077821012%\"><\/div><div class=\"mdx-img-loading-sp mdui-valign\"><div><div class=\"mdui-spinner\"><\/div><\/div><\/div><img width=\"514\" height=\"268\" class=\"lazyload\" title=\"jQuery\u4e0eMooTools\u5e93\u7684\u4e00\u4e9b\u6bd4\u5bf9\" src=\"data:image\/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==\" data-src=\"http:\/\/image.zhangxinxu.com\/image\/blog\/201109\/2011-09-27_172010.png\" alt=\"http:\/\/image.zhangxinxu.com\/image\/blog\/201109\/2011-09-27_172010.png\"><\/figure>\n<p><strong>dom\u64cd\u4f5c\u6027\u80fd<\/strong><\/p>\n<p>\u672c\u6765\u60f3\u4ece\u7f51\u4e0a\u627e\u4e00\u4e0bMooTools\u548cjQuery\u6846\u67b6\u5728dom\u64cd\u4f5c\u8fd9\u5757\u7684\u6027\u80fd\u5bf9\u6bd4\u6570\u636e\uff0c\u7ed3\u679c\u53d1\u73b0\uff0c\u538b\u6839\u5c31\u6ca1\u6709\uff0c\u8fde\u4e2a\u6cbe\u8fb9\u7684\u90fd\u6ca1\u6709\u3002\u5728\u8fd9\u8270\u96be\u56f0\u82e6\u7684\u65f6\u5019\uff0c\u60f3\u8d77\u4e86\u4f1f\u5927\u9886\u8896\u6bdb\u4e3b\u5e2d\u7684\u4e00\u53e5\u8bdd\uff1a\u201c\u81ea\u529b\u66f4\u751f\uff0c\u8270\u82e6\u521b\u4e1a\u201d\u3002\u5fc3\u4e2d\u7684\u5c0f\u5b87\u5b99\u987f\u65f6\u7206\u53d1\u4e86\uff0c\u5feb\u5200\u4e71\u9ebb\uff0c\u4e00\u756a\u6298\u817e\u540e\u5f04\u51fa\u4e86\u81ea\u5df1\u60f3\u8981\u7684\u6d4b\u8bd5\u9875\u9762\u3002<\/p>\n<p>\u60a8\u53ef\u4ee5\u72e0\u72e0\u5730\u70b9\u51fb\u8fd9\u91cc\uff1a<a class=\"a_link\" style=\"color: #ff3300;\" href=\"http:\/\/www.zhangxinxu.com\/study\/201109\/jquery-mootools-dom-operate-speed-test.html\" target=\"_blank\">MooTools\u4e0ejQuery\u4e00\u4e9bdom\u64cd\u4f5c\u6027\u80fd\u5bf9\u6bd4<\/a><\/p>\n<p>\u4e0b\u9762\u5c31\u662f\u6d4b\u8bd5\u7ed3\u679c\u54c8\uff1a<\/p>\n<table class=\"table_test\">\n<thead id=\"thead\">\n<tr>\n<th class=\"selectors-title\" style=\"font-weight: bold; color: #8a7575;\">attr<\/th>\n<th class=\"framework\" style=\"font-weight: bold; color: #8a7575;\">MooTools 1.3.1<\/th>\n<th class=\"framework\" style=\"font-weight: bold; color: #8a7575;\">JQuery 1.5.1<\/th>\n<\/tr>\n<\/thead>\n<tbody id=\"tbody\">\n<tr>\n<th class=\"selector\" style=\"font-weight: bold; color: #528ce0;\">setStyle\/css<\/th>\n<td class=\"test bad\" style=\"font-weight: bold; color: #b33f3f;\">79 ms | 1 found<\/td>\n<td class=\"test good\" style=\"font-weight: bold; color: #657528;\">53 ms | 1 found<\/td>\n<\/tr>\n<tr>\n<th class=\"selector\" style=\"font-weight: bold; color: #528ce0;\">setStyles\/cssMulti<\/th>\n<td class=\"test bad\" style=\"font-weight: bold; color: #b33f3f;\">200 ms | 1 found<\/td>\n<td class=\"test good\" style=\"font-weight: bold; color: #657528;\">109 ms | 1 found<\/td>\n<\/tr>\n<tr>\n<th class=\"selector\" style=\"font-weight: bold; color: #528ce0;\">setProperty\/attr<\/th>\n<td class=\"test good\" style=\"font-weight: bold; color: #657528;\">37 ms | 1 found<\/td>\n<td class=\"test bad\" style=\"font-weight: bold; color: #b33f3f;\">43 ms | 1 found<\/td>\n<\/tr>\n<tr>\n<th class=\"selector\" style=\"font-weight: bold; color: #528ce0;\">setProperties\/attrMulti<\/th>\n<td class=\"test good\" style=\"font-weight: bold; color: #657528;\">51 ms | 1 found<\/td>\n<td class=\"test bad\" style=\"font-weight: bold; color: #b33f3f;\">55 ms | 1 found<\/td>\n<\/tr>\n<tr>\n<th class=\"selector\" style=\"font-weight: bold; color: #528ce0;\">addClass<\/th>\n<td class=\"test bad\" style=\"font-weight: bold; color: #b33f3f;\">40 ms | 1 found<\/td>\n<td class=\"test good\" style=\"font-weight: bold; color: #657528;\">18 ms | 1 found<\/td>\n<\/tr>\n<tr>\n<th class=\"selector\" style=\"font-weight: bold; color: #528ce0;\">addClassMulti<\/th>\n<td class=\"test bad\" style=\"font-weight: bold; color: #b33f3f;\">54 ms | 1 found<\/td>\n<td class=\"test good\" style=\"font-weight: bold; color: #657528;\">25 ms | 1 found<\/td>\n<\/tr>\n<tr>\n<th class=\"selector\" style=\"font-weight: bold; color: #528ce0;\">hasClass<\/th>\n<td class=\"test bad\" style=\"font-weight: bold; color: #b33f3f;\">75 ms | 1 found<\/td>\n<td class=\"test good\" style=\"font-weight: bold; color: #657528;\">24 ms | 1 found<\/td>\n<\/tr>\n<tr>\n<th class=\"selector\" style=\"font-weight: bold; color: #528ce0;\">removeClass<\/th>\n<td class=\"test bad\" style=\"font-weight: bold; color: #b33f3f;\">118 ms | 1 found<\/td>\n<td class=\"test good\" style=\"font-weight: bold; color: #657528;\">23 ms | 1 found<\/td>\n<\/tr>\n<tr>\n<th class=\"selector\" style=\"font-weight: bold; color: #528ce0;\">removeClassMulti<\/th>\n<td class=\"test bad\" style=\"font-weight: bold; color: #b33f3f;\">109 ms | 1 found<\/td>\n<td class=\"test good\" style=\"font-weight: bold; color: #657528;\">10 ms | 1 found<\/td>\n<\/tr>\n<\/tbody>\n<tfoot id=\"tfoot\">\n<tr>\n<th class=\"score-title\" style=\"font-weight: bold; color: #8a7575;\"><strong>\u6700\u7ec8\u7ed3\u679c(\u8d8a\u5c0f\u8d8a\u597d)<\/strong><\/th>\n<td class=\"score\" style=\"font-weight: bold; color: #8a7575;\">\u00a0763<\/td>\n<td class=\"score\" style=\"font-weight: bold; color: #8a7575;\">\u00a0360<\/td>\n<\/tr>\n<\/tfoot>\n<\/table>\n<p>\u53ef\u4ee5\u770b\u5230\uff0c\u9664\u4e86<code>setProperty\/attr<\/code>\u548c<code>setProperties\/attrMulti<\/code>\u65b9\u6cd5MooTools\u6846\u67b6\u6027\u80fd\u662f\u7565\u5fae\u5360\u4f18\u5916\uff0c\u5176\u4f59\u4e00\u4e9bdom\u76f8\u5173\u64cd\u4f5c\u90fd\u5b8c\u8d25jQuery\u3002<\/p>\n<p>\u5c0f\u5c0f\u603b\u7ed3\uff1a\u5c31\u6027\u80fd\u8fd9\u5757\u3002MooTools\u6846\u67b6\u65e0\u8bba\u662f\u9009\u62e9\u5668\u6216\u662f\u5176\u4ed6\u4e00\u4e9b\u65b9\u6cd5\u6027\u80fd\u90fd\u900a\u4e8ejQuery\u3002<\/p>\n<h3>\u4e09\u3001MooTools\u7684\u4f18\u52bf\u5728\u4e8e\uff1f<\/h3>\n<p>\u6839\u636e\u4e0a\u9762\u4e24\u9879\u7684\u5bf9\u6bd4\uff0cMooTools\u6846\u67b6\u5728API\u65b9\u9762\u6ca1\u6709jQuery\u4f18\u79c0\uff0c\u4e00\u4e9bDOM\u76f8\u5173\u64cd\u4f5c\u6027\u80fd\u4e5f\u6ca1\u6709jQuery\u597d\uff0c\u90a3\u6211\u4eec\u8fd8\u6709\u4ec0\u4e48\u7406\u7531\u9009\u62e9MooTools\u6846\u67b6\u5462\uff1fMooTools\u6846\u67b6\u7684\u4f18\u52bf\u5728\u4ec0\u4e48\u5730\u65b9\u5462\uff1f<\/p>\n<p>\u5728\u8bb2\u8ff0MooTools\u4f18\u52bf\u4e4b\u524d\u6211\u60f3\u8bb2\u70b9\u9898\u5916\u8bdd\uff0c\u6709\u4f4dMooTools\u56e2\u961f\u6210\u5458\u66fe\u8bf4\u5982\u5982\u4e0b\u8ba9\u4eba\u503c\u5f97\u601d\u8003\u7684\u8bdd\uff1a<\/p>\n<blockquote style=\"color: #777777;\"><p>The MooTools team (of which I am a part) has never really focused on how popular the framework is. We are interested in writing it for our own use and for its own sake, but we don\u2019t really spend much energy trying to convince other people to use it. We don\u2019t consider ourselves adversaries to other frameworks \u2013 as I\u2019ve heard it put on numerous recent occassions, we\u2019re at war with the browsers, not each other. In my own posts on the topic, my suggestion to people is to try a couple of options and choose the framework that suits your needs and your styles. You really can\u2019t make a bad choice (so please stop arguing about it!). jQuery, Prototype. YUI, Dojo, MooTools \u2013 we\u2019re all doing the same things just using different methods.<\/p>\n<p>MooTools\u56e2\u961f\uff08\u6211\u4e5f\u662f\u5176\u4e2d\u4e4b\u4e00\uff09\u4ece\u6765\u6ca1\u6709\u771f\u6b63\u5173\u6ce8\u8fc7\u8fd9\u4e2a\u6846\u67b6\u6709 \u591a\u53d7\u6b22\u8fce\u3002\u6211\u4eec\u53ea\u662f\u5bf9\u5199\u8fd9\u4e2a\u6846\u67b6\u611f\u5174\u8da3\uff0c\u4e3a\u6211\u4eec\u81ea\u5df1\u4f7f\u7528\u548c\u5b83\u672c\u8eab\u76ee\u7684\u53bb\u5199\uff0c\u4f46\u662f\u6211\u4eec\u771f\u7684\u6ca1\u6709\u82b1\u5f88\u591a\u7cbe\u529b\u53bb\u8ba9\u5176\u4ed6\u4eba\u53bb\u4f7f\u7528\u8fd9\u4e2a\u6846\u67b6\u3002\u6211\u4eec\u4ece\u4e0d\u8ba4\u4e3a\u5176\u5b83\u6846\u67b6\u662f \u6211\u4eec\u7684\u7ade\u4e89\u5bf9\u624b\u2014\u2014\u56e0\u4e3a\u6211\u66fe\u7ecf\u5728\u5f88\u591a\u573a\u5408\u90fd\u542c\u8bf4\u8fc7\u8fd9\u6837\u7684\u8bdd\uff0c\u6211\u4eec\u5728\u548c\u6d4f\u89c8\u5668\u8fdb\u884c\u6597\u4e89\uff0c\u800c\u4e0d\u662f\u76f8\u4e92\u6597\u4e89\u3002\u5728\u6211\u7684\u8fd9\u7bc7\u6587\u7ae0\u4e2d\uff0c\u6211\u7ed9\u4f60\u4eec\u7684\u5efa\u8bae\u662f\uff1a\u591a\u5c1d\u8bd5\u4e00\u4e9b\u9009\u62e9\uff0c\u7136\u540e\u9009\u62e9\u9002\u5408\u4f60\u7684\u9700\u6c42\u548c\u4f60\u7684\u98ce\u683c\u7684\u6846\u67b6\u3002\u4f60\u771f\u7684\u4e0d\u80fd\u505a\u4e00\u4e2a\u574f\u7684\u9009\u62e9\uff08\u56e0\u6b64\uff0c\u8bf7\u505c\u6b62\u4e89\u5435\uff01\uff09\u3002jQuery\u3001Prototype\u3001YUI\u3001Dojo\u3001 MooTools\u2014\u2014\u6211\u4eec\u90fd\u53ea\u662f\u7528\u4e0d\u540c\u7684\u65b9\u6cd5\u5728\u505a\u540c\u6837\u7684\u4e8b\u3002<\/p><\/blockquote>\n<p>\u5f53\u521d\u6211\u7b2c\u4e00\u6b21\u542c\u53f2\u4ef2\u51ac\u8bf4MooTools\u5e93\u7684\u65f6\u5019\uff0c\u5fc3\u91cc\u6709\u5600\u5495\uff1a\u8fd9\u73a9\u610f\uff0c\u57fa\u672c\u4e0a\u90fd\u6ca1\u542c\u8fc7\uff0c\u4e5f\u6ca1\u6709\u4ec0\u4e48\u4eba\u4f7f\u7528\uff0c\u5e94\u8be5\u662f\u4e2a\u7a00\u5947\u53e4\u602a\uff0c\u7cdf\u7cd5\u7684\u6846\u67b6\u5427\u3002\u4f46\u662f\uff0c\u5f53\u6211\u9010\u6e10\u4e86\u89e3\u8fd9\u4e2aJS\u6846\u67b6\u540e\uff0c\u8d8a\u6765\u8d8a\u559c\u6b22\u4e4b\uff0c\u5176\u559c\u6b22\u7a0b\u5ea6\u5df2\u7ecf\u8d85\u8fc7jQuery\uff0c\u56e0\u4e3a\u5b83\u6bd4jQuery\u66f4\u9002\u5408\u5f53\u524d\u6211\u6240\u505a\u7684\u9879\u76ee\u2014\u2014\u9879\u76ee\u5927\uff0c\u5927\u6570\u636e\u91cf\u5904\u7406\u4ee5\u53ca\u5f88\u591a\u590d\u6742\u4ea4\u4e92\u3002<\/p>\n<p>jQuery\u7684\u56e0\u4e3a\u5176\u51fa\u8272\u7684API\uff0c\u4f7f\u5f97\u5373\u4f7f\u4e0d\u600e\u4e48\u61c2JavaScript\u7684\u4eba\u4e5f\u80fd\u5199\u51fa\u4e00\u4e9b\u81ea\u4ee5\u4e3a\u9760\u8c31\u7684\u4ee3\u7801\u3002\u518d\u52a0\u4e0ajQuery\u7684\u91cd\u5fc3\u653e\u5728\u4e86DOM\u4e0a\uff0c\u8fd9\u6b63\u597d\u8ba8\u4e86\u70ed\u8877\u4e8e\u9875\u9762\u6548\u679c\u4ea4\u4e92\u7684\u4e00\u4e9bdesigner\u548ccsser\u7684\u6b22\u5fc3\u3002\u5982\u679c\u8981\u6784\u5efa\u4e2d\u5c0f\u578b\u52a8\u6001Web\u7ad9\u70b9\uff0c\u7528jQuery\u6ca1\u9519\u3002\u5feb\u901f\u3001\u7b80\u5355\u3001\u4f18\u96c5\u3001\u6f02\u4eae\u3002\u5982\u679c\u6211\u662f\u4e00\u4e2a\u8bbe\u8ba1\u8005\uff0c\u6211\u4e5f\u4f1a\u4f7f\u7528\u5b83\u7684\u3002<\/p>\n<p>\u4f46\u662f\uff0c\u5982\u679c\u662f\u6709\u7740\u6210\u767e\u4e0a\u5343\u9875\u9762\u7684\u5927\u9879\u76ee\uff0c\u6709\u4e9b\u5927\u6570\u636e\u91cf\u4ea4\u4e92\u4e0e\u5904\u7406\u7684\u9879\u76ee\uff0c\u591a\u4eba\u5408\u4f5c\uff0c\u591a\u6a21\u5757\u5316\u7684\u9879\u76ee\uff0cjQuery\u5f80\u5f80\u5c31\u663e\u5f97\u5e95\u6c14\u4e0d\u8db3\uff0c\u5f80\u5f80\u9700\u8981\u5404\u7c7b\u63d2\u4ef6\u8865\u5145\u3002\u8981\u77e5\u9053\uff0cjQuery\u63d2\u4ef6\u6210\u767e\u4e0a\u5343\uff0c\u4f46\u5927\u591a\u90fd\u662f\u72d7\u5c4e\u3002\u5982\u679c\u6ca1\u6709\u725b\u4eba\u628a\u63a7\uff0c\u9879\u76ee\u6700\u540e\u4e5f\u5c31\u53d8\u6210\u4e86\u72d7\u5c4e\uff01<\/p>\n<p>MooTools\u867d\u7136\u4e5f\u80fd\u7528\u5728\u4e2d\u5c0f\u9879\u76ee\u4e0a\uff0c\u4f46\u662f\uff0c\u5176\u6f5c\u529b\u7684\u53d1\u6325\u8981\u5728\u5927\u578b\u3001\u9700\u8981\u7f16\u5199\u5927\u91cfJavaScript\u7684\u5e94\u7528\u7684\u7f51\u7ad9\u9879\u76ee\u4e0a\u3002\u8fd9\u5c31\u662fMooTools\u7684\u4f18\u52bf\u3002\u5f53\u7136\uff0c\u6211\u8bf4\u8bdd\u90fd\u662f\u8bb2\u8bc1\u636e\u7684\uff0c\u4e0b\u9762\u6211\u5c31\u6311\u51e0\u70b9\u8bf4\u8bf4\u4e3a\u4f55\u5927\u578b\u7f51\u7ad9\u9879\u76ee\u66f4\u9002\u5408MooTools\u800c\u4e0d\u662fjQuery\u3002<\/p>\n<p><strong>\u66f4\u591a\u7684\u5bf9\u8c61\u65b9\u6cd5\u6269\u5c55<\/strong><br \/>\n\u867d\u7136\u8bf4\uff0cMooTools\u6846\u67b6\u76f4\u63a5\u5728Array, Function\u5bf9\u8c61\u4e0a\u505a\u65b9\u6cd5\u6269\u5c55\u6709\u53ef\u80fd\u4f1a\u9020\u6210\u8bed\u540e\u6765JavaScript\u89c4\u8303\u51fa\u73b0\u91cd\u590d\u6216\u51b2\u7a81\u7684\u60c5\u51b5\uff0c\u4f46\u662f\uff0c\u4e0d\u53ef\u5426\u8ba4\u7684\u662f\uff0c\u8fd9\u4e9b\u5bf9\u8c61\u65b9\u6cd5\u7684\u6269\u5c55\u5bf9\u6211\u4eec\u7684\u5f00\u53d1\u8282\u7ea6\u4e86\u5f88\u591a\u7684\u529f\u592b\u3002<\/p>\n<p>\u4f8b\u5982\u5b57\u7b26\u4e32\u65b9\u6cd5\u7684\u6269\u5c55\u3002\u5728jQuery\u4e2d\uff0c\u5b57\u7b26\u4e32\u76f8\u5173\u64cd\u4f5c\u7684\u65b9\u6cd5\u8c8c\u4f3c\u5c31\u53ea\u6709\u4e00\u4e2a<code>trim<\/code>\u3002<br \/>\n\u4f46\u662f\uff0c\u5728MooTools\u4e2d\uff0c\u6846\u67b6\u81ea\u5e26\u5b57\u7b26\u4e32\u6269\u5c55\u65b9\u6cd5\u5c31\u670914\u4e2a\u4e4b\u591a\uff0c\u4f8b\u5982\u5b57\u7b26\u4e32\u5185\u5bb9\u68c0\u6d4b\u7684<code>contains<\/code>\u65b9\u6cd5\uff0c\u6e05\u9664\u6574\u4e2a\u5b57\u7b26\u4e32\u4e2d\u591a\u4f59\u7684\u7a7a\u767d\u5b57\u7b26\u4e32\u7684<code>clean<\/code>\u65b9\u6cd5\uff0c\u8f6c\u4e49\u6b63\u5219\u8868\u8fbe\u5f0f\u654f\u611f\u5b57\u7b26\u7684<code>escapeRegExp<\/code>\u65b9\u6cd5\uff0c\u6216\u662f\u53d6\u6574<code>toInt()<\/code>\u4ee5\u53cargb\u989c\u8272\u548c16\u8fdb\u5236\u989c\u8272\u76f8\u5173\u8f6c\u5316\u7684\u5b57\u7b26\u4e32\u65b9\u6cd5\u7b49\u7b49\u3002\u5728\u5927\u6570\u636e\u91cf\u4ea4\u4e92\u7684\u65f6\u5019\uff0c\u5b57\u7b26\u4e32\u76f8\u5173\u5904\u7406\u662f\u5f88\u591a\u7684\uff0cMooTools\u6846\u67b6\u81ea\u5e26\u7684\u8fd9\u4e9b\u5b57\u7b26\u4e32\u6269\u5c55\u65b9\u6cd5\u4e0d\u53ef\u4e0d\u8c13\u5e26\u6765N\u591a\u4fbf\u6377\u3002<\/p>\n<p>\u4e0d\u4ec5\u4ec5\u662f\u5b57\u7b26\u4e32\uff0cMooTools\u5bf9\u6570\u503c\uff0c\u51fd\u6570\u4ee5\u53ca\u6570\u7ec4\u5bf9\u8c61\u90fd\u8fdb\u884c\u4e86\u6269\u5c55\u3002\u5c24\u5176\u6570\u7ec4\uff0c\u9664\u4e86\u5176\u539f\u751f\u7684\u65b9\u6cd5\u5916\uff0cMooTools\u8fd8\u5bf9\u5176\u6269\u5c55\u4e86\u8fd120\u4e2a\u65b9\u6cd5\u3002\u8fd9\u4f7f\u5f97\u5076\u4eec\u5728\u5904\u7406\u6570\u7ec4\u7684\u65f6\u5019\u57fa\u672c\u4e0a\u6240\u5411\u62ab\u9761\u4e86\u3002\u603b\u4e4b\uff0cMooTools\u6846\u67b6\u5728\u5404\u7c7bJavaScript\u7c7b\u578b\u5bf9\u8c61\u4e0a\u505a\u4e86\u65b0\u65b9\u6cd5\u7684\u6269\u5c55\uff0c\u4ee5\u4fbf\u6211\u4eec\u53ef\u4ee5\u66f4\u8f7b\u677e\u66f4\u7b80\u5355\u5730\u5e94\u4ed8\u5404\u7c7b\u590d\u6742\u5e94\u7528\u548c\u4f17\u591a\u6570\u636e\u5904\u7406\u3002\u8fd9\u663e\u7136\u4e0ejQuery\u91cd\u5728DOM\u7684\u8bbe\u8ba1\u7406\u5ff5\u4e0d\u540c\u4e86\u3002<\/p>\n<p><strong>\u6570\u636e\u5904\u7406\u5229\u5668\u4e4bHash\u6982\u5ff5<\/strong><br \/>\nHash\uff0c\u4fd7\u79f0\u54c8\u5e0c\uff0c\u662fjQuery\u4e2d\u6ca1\u6709\u800cMooTools\u4e2d\u6709\u4e14\u5f88\u8d5e\u7684\u4e00\u4e2a\u73a9\u610f\u3002Hash\u662f\u4e00\u4e2a\u91cd\u65b0\u5b9e\u73b0\u7684Object({}), \u88ab\u4e13\u95e8\u7528\u4e8e\u6570\u636e\u7684\u5b58\u53d6\uff0c\u548c\u539f\u6765\u7684Object({})\u7684\u533a\u522b\u662f\uff1a \u5b83\u4e0d\u4f1a\u5728\u8fdb\u884c\u5b58\u503c\uff0c\u53d6\u503c\u6216\u8fed\u4ee3\u7684\u65f6\u5019\u5904\u7406\u5bf9\u8c61\u7684prototype\u4e2d\u7684\u5185\u5bb9\u3002\u5728MooTools\u4e2d\uff0cHash\u5bf9\u8c61\u548cArray\u5bf9\u8c61(json\u57fa\u672c\u6784\u6210\u5566)\u8054\u5408\u4f7f\u7528\uff0c\u4e0d\u662f\u6211\u5439\uff0c\u518dTM\u5e9e\u6742\u7684\u6570\u636e\uff0c\u90fd\u80fd\u8f7b\u677e\u5e94\u4ed8\u3002\u8fd9\u8ba9\u6211\u60f3\u8d77\u4e86\u6211\u4eec\u5c0f\u79d8\u4e66\u9910\u5385\u8be6\u7ec6\u9875\u7684\u9009\u83dc\u4ea4\u4e92\uff0c\u5982\u679c\u6ca1\u6709Hash\u8fd9\u4e2a\u73a9\u610f\uff0c\u6211\u53ef\u771f\u4e0d\u77e5\u9053\u8be5\u5982\u4f55\u4e0b\u624b\uff1b\u6216\u53e5\u8bdd\u8bf4\uff0c\u5982\u679c\u4e0d\u662f\u4f7f\u7528\u7684MooTools\u4f5c\u4e3a\u6846\u67b6\uff0c\u800c\u662fjQuery\uff1b\u8fd9\u91cc\u7684\u590d\u6742\u7684\u4ea4\u4e92\u5b9e\u73b0\u4f30\u8ba1\u5c31\u662f\u4e00\u573a\u68a6\u4e86\u3002<\/p>\n<p><strong>\u9762\u5411\u5bf9\u8c61\u7684\u8bbe\u8ba1\u601d\u60f3<\/strong><br \/>\nMooTools\u662f\u4e00\u6b3e\u9762\u5411\u5bf9\u8c61\u7684\u8bbe\u8ba1\u601d\u60f3\u6846\u67b6\u3002\u8bb2\u6c42\u7ee7\u627f\uff0c\u6a21\u5757\u5316\u4e0e\u91cd\u7528\u6027\u3002\u867d\u7136\u8bf4\u5176<code>new Class({})<\/code>\u7684\u6784\u9020\u6709\u4e9b\u8ba9\u4eba\u4e0d\u597d\u7406\u89e3\uff0c\u4f7f\u7528\u4e5f\u9887\u6709\u4e9b\u65e2\u5b9a\u89c4\u5219\uff0c\u4f46\u662f\uff0c\u5b9e\u9645\u4e0a\uff0c\u8fd9\u73a9\u610f\u8981\u662f\u80fd\u201c\u633a\u8fc7\u53bb\u201d\uff0c\u8fd8\u771f\u7684\u5f88\u6709\u7528\u7684\u3002\u4e3e\u4e2a\u5173\u4e8e\u534a\u900f\u660e\u906e\u7f69\u5c42\u7684\u4f8b\u5b50\u5427\u3002\u6211\u4eec\u6784\u5efa\u4e00\u4e2a\u540d\u53ebOverlay\u7684\u7c7b\uff0c\u7136\u540e\u5176\u76f8\u5173\u7684\u4ee3\u7801\u5c31\u5982\u4e0b\uff1a<\/p>\n<div class=\"zxx_code\">\n<pre style=\"color: #0000ff;\">var Overlay = new Class({\r\n    Implements: [Options, Events],\r\n    getOptions: function() {\r\n        return {\r\n            name:'',\r\n            duration: 200,\r\n            colour: '#000',\r\n            opacity: 0.35,\r\n            zIndex: 99,\r\n            container: document.body,\r\n            onClick: $empty\r\n        };\r\n    },\r\n    initialize: function(options) {\r\n        <span style=\"color: green;\">\/\/......<\/span>\r\n        return this.position();\r\n    },\r\n    position: function() {\r\n        <span style=\"color: green;\">\/\/......<\/span>\r\n    },\r\n    show: function() { \r\n        <span style=\"color: green;\">\/\/......<\/span>\r\n    },\r\n    hide: function(dispose) {\r\n        <span style=\"color: green;\">\/\/......<\/span>\r\n    },\r\n    dispose: function() {\r\n        <span style=\"color: green;\">\/\/......<\/span>\r\n    }\r\n});<\/pre>\n<\/div>\n<p>\u4e8e\u662f\uff0c\u5f53\u6211\u4eec\u9700\u8981\u534a\u900f\u660e\u906e\u7f69\u5c42\u7684\u65f6\u5019\uff0c\u76f4\u63a5\uff1a<\/p>\n<div class=\"zxx_code\">\n<pre style=\"color: #0000ff;\">var myOverlay = new Overlay();<\/pre>\n<\/div>\n<p>Overlay\u7c7b\u4e2d\u7684<code>position<\/code>,\u00a0<code>hide<\/code>,\u00a0<code>show<\/code>\u7b49\u65b9\u6cd5\u90fd\u662f\u5916\u90e8\u53ef\u89c1\u7684\u3002\u6211\u4eec\u53ef\u662f\u4f7f\u7528\u7c7b\u4f3c\uff1a<\/p>\n<div class=\"zxx_code\">\n<pre style=\"color: #0000ff;\">myOverlay.hide()<\/pre>\n<\/div>\n<p>\u8ba9\u906e\u7f69\u5c42\u9690\u85cf\u3002\u5f53\u7136\uff0c\u6211\u4eec\u53ef\u4ee5\u518d\u5b9a\u4e49\u4e00\u4e2a\u65b0\u7684\u7c7b\uff0c\u8fd9\u4e2a\u7c7b\u7ee7\u627f\u6216\u4f7f\u7528Overlay\u7c7b\uff0c\u4f8b\u5982\u6211\u4eec\u5f88\u5e38\u7528\u7684\u5f39\u6846\u6548\u679c\u54af\uff0c\u7b49\u7b49\u3002\u867d\u7136\uff0cMooTools\u8fd9\u79cd\u5f3a\u5236\u9762\u5411\u5bf9\u8c61\u98ce\u683c\u7684\u8bbe\u8ba1\u6709\u4e9b\u6de1\u5316\u4e86JavaScript\u8bed\u8a00\u672c\u8eab\u7684\u4e00\u4e9b\u4f18\u7f8e\u7279\u6027\u3002\u4f46\u662f\uff0c\u5f53\u9879\u76ee\u5e9e\u5927\uff0cJavaScript\u4ee3\u7801\u91cf\u5de8\u5927\u7684\u65f6\u5019\uff0c\u8fd9\u79cd\u9762\u5411\u5bf9\u8c61\u7684\u8bbe\u8ba1\u7406\u5ff5\u8fd8\u662f\u76f8\u5f53\u53d7\u7528\u7684\u3002\u9879\u76ee\u8d8a\u5927\uff0c\u5076\u4eec\u6240\u8282\u7701\u7684\u4ee3\u7801\u91cf\u5c31\u8d8a\u591a\u3002<\/p>\n<p><strong>Cookie\u7684\u8bfb\u5199<\/strong><br \/>\nMooTools\u6846\u67b6\u81ea\u5e26Cookie\u8bfb\u5199\u7684\u65b9\u6cd5\uff0c\u652f\u6301\u6307\u5b9a\u57df\u548c\u8def\u5f84\u3002\u800cjQuery\u6846\u67b6\u4e2d\u8981\u60f3\u5b9e\u73b0Cookie\u7684\u8bfb\u5199\uff0c\u9700\u8981\u501f\u52a9\u4e8e\u4e13\u95e8\u7684cookie\u63d2\u4ef6\uff0c\u989d\u5916\u7684\u63d2\u4ef6\uff0c\u663e\u7136jQuery\u5c31\u6298\u817e\u4e86\u3002<a style=\"color: #34538b;\" href=\"http:\/\/www.zhangxinxu.com\/wordpress\/2011\/09\/html5-localstorage%e6%9c%ac%e5%9c%b0%e5%ad%98%e5%82%a8%e5%ae%9e%e9%99%85%e5%ba%94%e7%94%a8%e4%b8%be%e4%be%8b\/\">HTML5 localStorage\u672c\u5730\u5b58\u50a8\u5b9e\u9645\u5e94\u7528<\/a>\u8fd9\u7bc7\u6587\u7ae0\u7684IE\u6d4f\u89c8\u5668Cookie\u7684\u8bfb\u5199\u5c31\u662f\u4f7f\u7528MooTools\u6846\u67b6\u81ea\u5e26\u7684Cookie\u65b9\u6cd5\u3002\u5f88\u7b80\u5355\uff0c\u5f88\u597d\u4f7f\u7528\u3002<\/p>\n<p><strong>swf\u6587\u4ef6\u7684\u8f7d\u4eba<\/strong><br \/>\nMooTools\u6846\u67b6\u81ea\u5e26<code>Swiff<\/code>\u7c7b\uff0c\u53ef\u4ee5\u5b9e\u73b0\u9875\u9762\u4e0aflash\u6587\u4ef6\u7684\u8f7d\u5165\uff0c\u800c\u4e0d\u9700\u8981\u6c42\u52a9google\u7684<code>swfobject<\/code>\u65b9\u6cd5\u3002<\/p>\n<div id=\"swfBox\"><object id=\"Swiff_ij2glb7q\" width=\"300\" height=\"300\" type=\"application\/x-shockwave-flash\" data=\"http:\/\/www.zhangxinxu.com\/study\/flash\/as3_clock_2.swf\"><\/object><\/div>\n<p>\u4e0a\u9762\u8fd9\u4e2a\u949f\u8868flash\u7684\u6548\u679c\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n<div class=\"zxx_code\">\n<pre style=\"color: #0000ff;\">var obj = new Swiff('http:\/\/www.zhangxinxu.com\/study\/flash\/as3_clock_2.swf', {\r\n    width: 300,\r\n    height: 300,\r\n    container: $(\"swfBox\"),\r\n    params: {\r\n        wmode: 'opaque',\r\n        bgcolor: '#eeeeee'\r\n    }\r\n});<\/pre>\n<\/div>\n<p><strong>\u66f4\u5168\u9762\u7684\u52a8\u753b\u6548\u679c<\/strong><br \/>\nMooTools\u6846\u67b6\u7684\u52a8\u753b\u6548\u679c\u5b9e\u9645\u4e0a\u8981\u6bd4jQuery\u7684\u5f3a\u4e9b\uff0c\u4f46\u662f\uff0c\u4e0d\u8db3\u5728\u4e8e\u5176\u4f7f\u7528\u7684API\u8981\u6bd4jQuery\u900a\u8272\u3002<br \/>\n\u8bf4MooTools\u6846\u67b6\u52a8\u753b\u8981\u6bd4jQuery\u5f3a\uff0c\u5176\u4e2d\u4e4b\u4e00\u5c31\u662fMooTools\u52a8\u753b\u5185\u7f6e\u4e86\u8d1d\u585e\u5c14\u8fd0\u52a8\u66f2\u7ebf\u5173\u952e\u5b57\u3002\u5982\uff1a<code>'linear'<\/code>,\u00a0<code>'quad:in'<\/code>,\u00a0<code>'back:in'<\/code>,\u00a0<code>'bounce:out'<\/code>,\u00a0<code>'elastic:out'<\/code>,\u00a0<code>'sine:in:out'<\/code>\u7b49\u7b49\uff08\u4e0b\u56fe\u4e3aFx.Transitions\u65b9\u6cd5\u4e4b<code>expo<\/code>\uff09\uff0c\u800cjQuery\u5b9e\u73b0\u7c7b\u4f3c\u7f13\u52a8\u6548\u679c\uff0c\u8fd8\u9700\u8981\u501f\u52a9<code>ease<\/code>\u63d2\u4ef6\u3002<\/p>\n<figure class=\"mdx-lazyload-container\" style=\"\"><div style=\"padding-top:50%\"><\/div><div class=\"mdx-img-loading-sp mdui-valign\"><div><div class=\"mdui-spinner\"><\/div><\/div><\/div><img class=\"lazyload\" title=\"jQuery\u4e0eMooTools\u5e93\u7684\u4e00\u4e9b\u6bd4\u5bf9\" src=\"data:image\/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==\" data-src=\"http:\/\/www.zhangxinxu.com\/jq\/mt\/assets\/images\/graphs\/Expo.png\" alt=\"http:\/\/www.zhangxinxu.com\/jq\/mt\/assets\/images\/graphs\/Expo.png\"><\/figure>\n<p><strong>form\u8868\u5355\u5e8f\u5217\u5316\u63d0\u4ea4<\/strong><br \/>\nMooTools\u81ea\u8eab\u643a\u5e26HTML\u8868\u5355\u63a7\u4ef6\u5143\u7d20\u6570\u636e\u5e8f\u5217\u5316\u65b9\u6cd5\uff0c\u4f8b\u5982\uff1a<\/p>\n<div class=\"zxx_code\">\n<pre style=\"color: #0000ff;\">$('myForm').toQueryString(); <span style=\"color: green;\">\/\/\u8fd4\u56de \"email=bob@bob.com&amp;zipCode=90210\"<\/span><\/pre>\n<\/div>\n<p>\u8868\u5355\u5143\u7d20\u81ea\u8eab\u643a\u5e26\u4e86ajax\u63d0\u4ea4\u65b9\u6cd5\uff0c\u5982\u4e0b\u793a\u4f8b\uff1a<\/p>\n<div class=\"zxx_code\">\n<pre style=\"color: #0000ff;\">$('loginForm').addEvent('submit', function(e){\r\n    e.stop(); <span style=\"color: green;\"> \/\/\u4e0d\u63d0\u4ea4form<\/span>\r\n    $('loginForm').send({\r\n     onComplete: function(result) {\r\n         $('loginPopup').set('html', result); <span style=\"color: green;\">\/\/\u663e\u793a\u7ed3\u679c<\/span>\r\n         (function(){\r\n             $('loginPopup').hide();\r\n         }.delay(1000)); <span style=\"color: green;\">\/\/\u4e00\u79d2\u949f\u540e\u9690\u85cf<\/span>\r\n     }\r\n    });\r\n});<\/pre>\n<\/div>\n<p>\u800cjQuery\u6846\u67b6\u8981\u5b9e\u73b0\u7c7b\u4f3c\u7684\u529f\u80fd\uff0c\u8fd8\u9700\u8981\u4e13\u95e8\u7684\u8868\u5355\u5e8f\u5217\u5316\u63d2\u4ef6\u3002\u6211\u9760\uff0c\u8fd9\u4e1c\u4e00\u4e2a\u63d2\u4ef6\uff0c\u897f\u4e00\u4e2a\u63d2\u4ef6\uff0c\u800c\u4e14\u63d2\u4ef6\u8d28\u91cf\u826f\u83a0\u4e0d\u9f50\uff0c\u641e\u591a\u4e86\u4f1a\u6b7b\u4eba\u7684\u3002<\/p>\n<h3>\u56db\u3001\u6700\u540e\u7684\u5bf9\u6bd4\u603b\u7ed3<\/h3>\n<p>\u9996\u5148\uff0c\u6bcb\u5eb8\u7f6e\u7591\u7684\u662fjQuery\u548cMooTools\u90fd\u662f\u975e\u5e38\u4f18\u79c0\u7684\u8f7b\u91cf\u7ea7\u7684JavaScript\u6846\u67b6\u3002<\/p>\n<p>jQuery\u4ee5\u5176\u51fa\u8272\u7684API\uff0c\u51fa\u8272\u7684\u63d2\u4ef6\u673a\u5236\uff0c\u4ee5\u53ca\u5728DOM\u65b9\u9762\u7684\u5173\u6ce8\u4f7f\u5176\u5927\u53d7\u6b22\u8fce\u3002\u7136\u800c\uff0c\u5728\u9762\u5bf9\u5927\u578b\u9879\u76ee\u7684\u65f6\u5019\uff0c\u5176\u5728\u4e00\u4e9b\u529f\u80fd\u7279\u6027\u4e0a\u7684\u7f3a\u5931\u5f80\u5f80\u9700\u8981\u501f\u52a9\u63d2\u4ef6\u3002\u5982\u679c\u56e2\u961f\u6ca1\u6709\u6709\u725b\u4eba\u628a\u5173\u7684\u8bdd\uff0c\u63d2\u4ef6\u7684\u6ee5\u7528\uff0c\u4eba\u4eba\u90fd\u63d2\u4e00\u624b\u7684\u4ee3\u7801\u4f1a\u628a\u9879\u76ee\u4ee3\u7801\u8d28\u91cf\u9010\u6e10\u53d8\u6210\u72d7\u5c4e\u7684\u3002\u4e00\u822c\u800c\u8a00\uff0cjQuery\u66f4\u9002\u5408\u4e0e\u52a8\u6001\u7684\u4e2d\u5c0f\u7ad9\u70b9\u3002<\/p>\n<p>MooTools\u63d2\u4ef6\u867d\u7136\u5728API &amp; DOM\u548c\u4e0a\u624b\u5bb9\u6613\u7a0b\u5ea6\u4e0a\u90fd\u4e0a\u4e0d\u53cajQuery\uff0c\u4f46\u662f\uff0c\u5176API\u4ee5\u53ca\u9762\u5411\u5bf9\u8c61\u7684\u8bbe\u8ba1\u601d\u60f3\u4f3c\u4e4e\u5728\u5b9e\u9645\u7684\u5927\u9879\u76ee\u4e2d\u66f4\u6709\u4ef7\u503c\u3002<\/p>\n<p>\u56e0\u6b64\uff0c\u5982\u679c\u6211\u8981\u6298\u817e\u6211\u7684\u4e2a\u4eba\u7f51\u7ad9\uff0c\u5e94\u8be5\u4f1a\u4f7f\u7528jQuery\u3002\u4f46\u662f\uff0c\u5982\u679c\u662f\u516c\u53f8\u7684\u5927\u7684\u7f51\u7ad9\u9879\u76ee\uff0c\u6211\u4f1a\u575a\u5b9a\u4e0d\u79fb\u9009\u62e9MooTools\uff0c\u56e0\u4e3a\u66f4\u9002\u5408\u3002<\/p>\n<p>\u6211JS\u6c34\u5e73\u5c1a\u6d45\uff0c\u57fa\u672c\u4e0a\u90fd\u662f\u4e9b\u8868\u8c61\u7684\u5bf9\u6bd4\uff0c\u6b22\u8fce\u5410\u69fd\u3002<\/p>\n<p>&nbsp;<\/p>\n<p><a href=\"http:\/\/www.zhangxinxu.com\/wordpress\/2011\/09\/jquery%E4%B8%8Emootools%E5%BA%93%E7%9A%84%E4%B8%80%E4%BA%9B%E6%AF%94%E5%AF%B9\/\" target=\"_blank\">http:\/\/www.zhangxinxu.com\/wordpress\/2011\/09\/jquery\u4e0emootools\u5e93\u7684\u4e00\u4e9b\u6bd4\u5bf9\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6211\u4e0a\u5927\u5b66\u90a3\u4f1a\u513f\u4ece\u4e8b\u7684\u9879\u76ee\u7528\u7684\u662fjQuery\uff0c\u6bd5\u4e1a\u540e\u5de5\u4f5c\u6240\u4ece\u4e8b\u7684\u9879\u76ee\u7528\u7684\u662fMooTools\u3002\u5f88\u5e78\u8fd0\u77ed\u671f\u5185\u6709\u673a\u4f1a\u63a5 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[],"class_list":["post-4701","post","type-post","status-publish","format-standard","hentry","category-11"],"_links":{"self":[{"href":"https:\/\/sdeno.com\/index.php?rest_route=\/wp\/v2\/posts\/4701","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sdeno.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sdeno.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sdeno.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sdeno.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4701"}],"version-history":[{"count":0,"href":"https:\/\/sdeno.com\/index.php?rest_route=\/wp\/v2\/posts\/4701\/revisions"}],"wp:attachment":[{"href":"https:\/\/sdeno.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4701"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sdeno.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4701"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sdeno.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4701"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}