{"id":2999,"date":"2018-02-27T10:44:21","date_gmt":"2018-02-27T02:44:21","guid":{"rendered":"http:\/\/www.daliane.com\/?p=2999"},"modified":"2018-02-27T11:03:10","modified_gmt":"2018-02-27T03:03:10","slug":"dom_shi_jian_liu_de_san_ge_jie_duan","status":"publish","type":"post","link":"http:\/\/www.daliane.com\/category\/jinjiaoyou\/dom_shi_jian_liu_de_san_ge_jie_duan\/","title":{"rendered":"DOM\u4e8b\u4ef6\u6d41\u7684\u4e09\u4e2a\u9636\u6bb5"},"content":{"rendered":"<h2 id=\"\u6d41\" style=\"font-family:\u5fae\u8f6f\u96c5\u9ed1, HelveticaNeue-Light, &quot;font-weight:300;color:#574C4C;font-size:1.3em;background-color:#FFFFFF;vertical-align:baseline;\">\n\t\u6d41<br \/>\n<\/h2>\n<p style=\"font-size:16px;color:#4F4F4F;text-align:justify;background-color:#FFFFFF;font-family:\u5fae\u8f6f\u96c5\u9ed1, HelveticaNeue-Light, &quot;vertical-align:baseline;\">\n\t\u6d41\u7684\u6982\u5ff5\uff0c\u5728\u73b0\u4eca\u7684JavaScript\u4e2d\u968f\u5904\u53ef\u89c1\u3002\u6bd4\u5982\u8bf4React\u4e2d\u7684\u5355\u5411\u6570\u636e\u6d41\uff0cNode\u4e2d\u7684\u6d41\uff0c\u53c8\u6216\u662f\u4eca\u5929\u672c\u6587\u6240\u8bb2\u7684DOM\u4e8b\u4ef6\u6d41\u3002\u90fd\u662f\u6d41\u7684\u4e00\u79cd\u751f\u52a8\u4f53\u73b0\u3002<br \/>\n\u81f3\u4e8e\u6d41\u7684\u5177\u4f53\u6982\u5ff5\uff0c\u6211\u4eec\u91c7\u7528\u4e0b\u6587\u7684\u89e3\u91ca\uff1a\n<\/p>\n<blockquote style=\"font-size:16px;color:#4F4F4F;font-family:\u5fae\u8f6f\u96c5\u9ed1, HelveticaNeue-Light, &quot;vertical-align:baseline;background:#F6F6F6;\">\n<p style=\"font-weight:inherit;text-align:justify;font-style:inherit;font-family:inherit;vertical-align:baseline;\">\n\t\t\u7528\u672f\u8bed\u8bf4\u6d41\u662f\u5bf9\u8f93\u5165\u8f93\u51fa\u8bbe\u5907\u7684\u62bd\u8c61\u3002\u4ee5\u7a0b\u5e8f\u7684\u89d2\u5ea6\u8bf4\uff0c\u6d41\u662f\u5177\u6709\u65b9\u5411\u7684\u6570\u636e\u3002\n\t<\/p>\n<\/blockquote>\n<h2 id=\"\u4e8b\u4ef6\u6d41\u4e4b\u4e8b\u4ef6\u5192\u6ce1\u4e0e\u4e8b\u4ef6\u6355\u83b7\" style=\"font-family:\u5fae\u8f6f\u96c5\u9ed1, HelveticaNeue-Light, &quot;font-weight:300;color:#574C4C;font-size:1.3em;background-color:#FFFFFF;vertical-align:baseline;\">\n\t<a name=\"t2\"><\/a><a target=\"_blank\" href=\"http:\/\/lxxyx.win\/2016\/02\/17\/%E5%AF%92%E5%81%87%E5%89%8D%E7%AB%AF%E5%AD%A6%E4%B9%A0(10)%E2%80%94%E2%80%94%E7%90%86%E8%A7%A3DOM%E4%BA%8B%E4%BB%B6%E6%B5%81%E7%9A%84%E4%B8%89%E4%B8%AA%E9%98%B6%E6%AE%B5\/#%E4%BA%8B%E4%BB%B6%E6%B5%81%E4%B9%8B%E4%BA%8B%E4%BB%B6%E5%86%92%E6%B3%A1%E4%B8%8E%E4%BA%8B%E4%BB%B6%E6%8D%95%E8%8E%B7\" class=\"headerlink\"><\/a>\u4e8b\u4ef6\u6d41\u4e4b\u4e8b\u4ef6\u5192\u6ce1\u4e0e\u4e8b\u4ef6\u6355\u83b7<br \/>\n<\/h2>\n<p style=\"font-size:16px;color:#4F4F4F;text-align:justify;background-color:#FFFFFF;font-family:\u5fae\u8f6f\u96c5\u9ed1, HelveticaNeue-Light, &quot;vertical-align:baseline;\">\n\t\u5728\u6d4f\u89c8\u5668\u53d1\u5c55\u7684\u8fc7\u7a0b\u4e2d\uff0c\u5f00\u53d1\u56e2\u961f\u9047\u5230\u4e86\u4e00\u4e2a\u95ee\u9898\u3002\u90a3\u5c31\u662f\u9875\u9762\u4e2d\u7684\u54ea\u4e00\u90e8\u5206\u62e5\u6709\u7279\u5b9a\u7684\u4e8b\u4ef6\uff1f<br \/>\n\u53ef\u4ee5\u60f3\u8c61\u753b\u5728\u4e00\u5f20\u7eb8\u4e0a\u7684\u4e00\u7ec4\u540c\u5fc3\u5706\uff0c\u5982\u679c\u4f60\u628a\u624b\u6307\u653e\u5728\u5706\u5fc3\u4e0a\uff0c\u90a3\u4e48\u4f60\u7684\u624b\u6307\u6307\u5411\u7684\u5176\u5b9e\u4e0d\u662f\u4e00\u4e2a\u5706\uff0c\u800c\u662f\u7eb8\u4e0a\u6240\u6709\u7684\u5706\u3002\u653e\u5230\u5b9e\u9645\u9875\u9762\u4e2d\u5c31\u662f\uff0c\u4f60\u70b9\u51fb\u4e00\u4e2a\u6309\u94ae\uff0c\u4e8b\u5b9e\u4e0a\u4f60\u8fd8\u540c\u65f6\u70b9\u51fb\u4e86\u6309\u94ae\u6240\u6709\u7684\u7236\u5143\u7d20\u3002<br \/>\n\u5f00\u53d1\u56e2\u961f\u7684\u95ee\u9898\u5c31\u5728\u4e8e\uff0c\u5f53\u70b9\u51fb\u6309\u94ae\u65f6\uff0c\u662f\u6309\u94ae\u6700\u5916\u5c42\u7684\u7236\u5143\u7d20\u5148\u6536\u5230\u4e8b\u4ef6\u5e76\u6267\u884c\uff0c\u8fd8\u662f\u5177\u4f53\u5143\u7d20\u5148\u6536\u5230\u4e8b\u4ef6\u5e76\u6267\u884c\uff1f\u6240\u4ee5\u8fd9\u513f\u5f15\u5165\u4e86\u4e8b\u4ef6\u6d41\u7684\u6982\u5ff5\u3002\n<\/p>\n<blockquote style=\"font-size:16px;color:#4F4F4F;font-family:\u5fae\u8f6f\u96c5\u9ed1, HelveticaNeue-Light, &quot;vertical-align:baseline;background:#F6F6F6;\">\n<p style=\"font-weight:inherit;text-align:justify;font-style:inherit;font-family:inherit;vertical-align:baseline;\">\n\t\t\u4e8b\u4ef6\u6d41\u6240\u63cf\u8ff0\u7684\u5c31\u662f\u4ece\u9875\u9762\u4e2d\u63a5\u53d7\u4e8b\u4ef6\u7684\u987a\u5e8f\u3002\n\t<\/p>\n<\/blockquote>\n<p style=\"font-size:16px;color:#4F4F4F;text-align:justify;background-color:#FFFFFF;font-family:\u5fae\u8f6f\u96c5\u9ed1, HelveticaNeue-Light, &quot;vertical-align:baseline;\">\n\t\u56e0\u4e3a\u6709\u4e24\u79cd\u89c2\u70b9\uff0c\u6240\u4ee5\u4e8b\u4ef6\u6d41\u4e5f\u6709\u4e24\u79cd\uff0c\u5206\u522b\u662f\u4e8b\u4ef6\u5192\u6ce1\u548c\u4e8b\u4ef6\u6355\u83b7\u3002\u73b0\u884c\u7684\u4e3b\u6d41\u662f\u4e8b\u4ef6\u5192\u6ce1\u3002\n<\/p>\n<h3 id=\"\u4e8b\u4ef6\u5192\u6ce1\" style=\"font-family:\u5fae\u8f6f\u96c5\u9ed1, HelveticaNeue-Light, &quot;font-weight:300;color:#574C4C;font-size:1.1em;background-color:#FFFFFF;vertical-align:baseline;\">\n\t<a name=\"t3\"><\/a><a target=\"_blank\" href=\"http:\/\/lxxyx.win\/2016\/02\/17\/%E5%AF%92%E5%81%87%E5%89%8D%E7%AB%AF%E5%AD%A6%E4%B9%A0(10)%E2%80%94%E2%80%94%E7%90%86%E8%A7%A3DOM%E4%BA%8B%E4%BB%B6%E6%B5%81%E7%9A%84%E4%B8%89%E4%B8%AA%E9%98%B6%E6%AE%B5\/#%E4%BA%8B%E4%BB%B6%E5%86%92%E6%B3%A1\" class=\"headerlink\"><\/a>\u4e8b\u4ef6\u5192\u6ce1<br \/>\n<\/h3>\n<p style=\"font-size:16px;color:#4F4F4F;text-align:justify;background-color:#FFFFFF;font-family:\u5fae\u8f6f\u96c5\u9ed1, HelveticaNeue-Light, &quot;vertical-align:baseline;\">\n\t\u4e8b\u4ef6\u5192\u6ce1\u5373\u4e8b\u4ef6\u5f00\u59cb\u65f6\uff0c\u7531\u6700\u5177\u4f53\u7684\u5143\u7d20\u63a5\u6536\uff08\u4e5f\u5c31\u662f\u4e8b\u4ef6\u53d1\u751f\u6240\u5728\u7684\u8282\u70b9\uff09\uff0c\u7136\u540e\u9010\u7ea7\u4f20\u64ad\u5230\u8f83\u4e3a\u4e0d\u5177\u4f53\u7684\u8282\u70b9\u3002<br \/>\n\u4e3e\u4e2a\u6817\u5b50\uff0c\u5c31\u5f88\u5bb9\u6613\u660e\u767d\u4e86\u3002\n<\/p>\n<table style=\"width:auto;margin:0px;color:#454545;font-family:inherit;font-size:16px;font-style:inherit;font-weight:inherit;background-color:#FFFFFF;padding:0px;border:none;\">\n<tbody>\n<tr>\n<td class=\"gutter\" style=\"border:none;font-size:16px;color:#4F4F4F;font-style:inherit;font-family:inherit;vertical-align:middle;\">\n<pre><\/pre>\n<\/td>\n<td class=\"code\" style=\"border:none;font-size:16px;color:#4F4F4F;font-style:inherit;font-family:inherit;vertical-align:middle;\">\n<pre>\r\n<\/pre>\n<pre class=\"prettyprint lang-html\">&lt;!DOCTYPE html&gt;\r\n&lt;html lang=\"en\"&gt;\r\n&lt;head&gt;\r\n  &lt;meta charset=\"UTF-8\"&gt;\r\n  &lt;title&gt;Event Bubbling&lt;\/title&gt;\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n  &lt;button id=\"clickMe\"&gt;Click Me&lt;\/button&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;\r\n<\/pre>\n<p>\u7136\u540e\uff0c\u6211\u4eec\u7ed9button\u548c\u5b83\u7684\u7236\u5143\u7d20\uff0c\u52a0\u5165\u70b9\u51fb\u4e8b\u4ef6\u3002\n\t\t\t<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><\/p>\n<table style=\"width:auto;margin:0px;color:#454545;font-family:inherit;font-size:16px;font-style:inherit;font-weight:inherit;background-color:#FFFFFF;padding:0px;border:none;\">\n<tbody>\n<tr>\n<td class=\"gutter\" style=\"border:none;font-size:16px;color:#4F4F4F;font-style:inherit;font-family:inherit;vertical-align:middle;\">\n<pre><\/pre>\n<\/td>\n<td class=\"code\" style=\"border:none;font-size:16px;color:#4F4F4F;font-style:inherit;font-family:inherit;vertical-align:middle;\">\n<pre>\r\n<\/pre>\n<pre class=\"prettyprint lang-js\">var button = document.getElementById('clickMe');\r\n\r\nbutton.onclick = function() {\r\n  console.log('1. You click Button');\r\n};\r\ndocument.body.onclick = function() {\r\n  console.log('2. You click body');\r\n};\r\ndocument.onclick = function() {\r\n  console.log('3. You click document');\r\n};\r\nwindow.onclick = function() {\r\n  console.log('4. You click window');\r\n};<\/pre>\n<p><\/p>\n<pre>\u6548\u679c\u5982\u56fe\u6240\u793a\uff1a<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p style=\"font-size:16px;color:#4F4F4F;text-align:justify;background-color:#FFFFFF;font-family:\u5fae\u8f6f\u96c5\u9ed1, HelveticaNeue-Light, &quot;vertical-align:baseline;\">\n\t<a target=\"_blank\" href=\"http:\/\/www.daliane.com\/wp-content\/uploads\/2018\/02\/dom1.png\" class=\"fancy-ctn fancybox\"><br \/>\n<img decoding=\"async\" src=\"http:\/\/www.daliane.com\/wp-content\/uploads\/2018\/02\/dom1.png\" title=\"\u4e8b\u4ef6\u5192\u6ce1\u793a\u4f8b\u56fe\" alt=\"\" \/><\/a>\n<\/p>\n<p style=\"font-size:16px;color:#4F4F4F;text-align:justify;background-color:#FFFFFF;font-family:\u5fae\u8f6f\u96c5\u9ed1, HelveticaNeue-Light, &quot;vertical-align:baseline;\">\n\t\u5728\u4ee3\u7801\u6240\u793a\u7684\u9875\u9762\u4e2d\uff0c\u5982\u679c\u70b9\u51fb\u4e86button\uff0c\u90a3\u4e48\u8fd9\u4e2a\u70b9\u51fb\u4e8b\u4ef6\u4f1a\u6309\u5982\u4e0b\u7684\u987a\u5e8f\u4f20\u64ad\uff08Chrome\u6d4f\u89c8\u5668\uff09\uff1a\n<\/p>\n<ol style=\"color:#454545;background-color:#FFFFFF;font-family:\u5fae\u8f6f\u96c5\u9ed1, HelveticaNeue-Light, &quot;font-size:14px;vertical-align:baseline;\">\n<li style=\"font-weight:inherit;font-style:inherit;font-family:inherit;vertical-align:baseline;\">\n\t\tbutton\n\t<\/li>\n<li style=\"font-weight:inherit;font-style:inherit;font-family:inherit;vertical-align:baseline;\">\n\t\tbody\n\t<\/li>\n<li style=\"font-weight:inherit;font-style:inherit;font-family:inherit;vertical-align:baseline;\">\n\t\tdocument\n\t<\/li>\n<li style=\"font-weight:inherit;font-style:inherit;font-family:inherit;vertical-align:baseline;\">\n\t\twindow\n\t<\/li>\n<\/ol>\n<p style=\"font-size:16px;color:#4F4F4F;text-align:justify;background-color:#FFFFFF;font-family:\u5fae\u8f6f\u96c5\u9ed1, HelveticaNeue-Light, &quot;vertical-align:baseline;\">\n\t\u4e5f\u5c31\u662f\u8bf4\uff0cclick\u4e8b\u4ef6\u9996\u5148\u5728&lt;button&gt;\u5143\u7d20\u4e0a\u53d1\u751f\uff0c\u7136\u540e\u9010\u7ea7\u5411\u4e0a\u4f20\u64ad\u3002\u8fd9\u5c31\u662f\u4e8b\u4ef6\u5192\u6ce1\u3002\n<\/p>\n<h3 id=\"\u4e8b\u4ef6\u6355\u83b7\" style=\"font-family:\u5fae\u8f6f\u96c5\u9ed1, HelveticaNeue-Light, &quot;font-weight:300;color:#574C4C;font-size:1.1em;background-color:#FFFFFF;vertical-align:baseline;\">\n\t<a name=\"t4\"><\/a><a target=\"_blank\" href=\"http:\/\/lxxyx.win\/2016\/02\/17\/%E5%AF%92%E5%81%87%E5%89%8D%E7%AB%AF%E5%AD%A6%E4%B9%A0(10)%E2%80%94%E2%80%94%E7%90%86%E8%A7%A3DOM%E4%BA%8B%E4%BB%B6%E6%B5%81%E7%9A%84%E4%B8%89%E4%B8%AA%E9%98%B6%E6%AE%B5\/#%E4%BA%8B%E4%BB%B6%E6%8D%95%E8%8E%B7\" class=\"headerlink\"><\/a>\u4e8b\u4ef6\u6355\u83b7<br \/>\n<\/h3>\n<p style=\"font-size:16px;color:#4F4F4F;text-align:justify;background-color:#FFFFFF;font-family:\u5fae\u8f6f\u96c5\u9ed1, HelveticaNeue-Light, &quot;vertical-align:baseline;\">\n\t\u4e8b\u4ef6\u6355\u83b7\u7684\u6982\u5ff5\uff0c\u4e0e\u4e8b\u4ef6\u5192\u6ce1\u6b63\u597d\u76f8\u53cd\u3002\u5b83\u8ba4\u4e3a\u5f53\u67d0\u4e2a\u4e8b\u4ef6\u53d1\u751f\u65f6\uff0c\u7236\u5143\u7d20\u5e94\u8be5\u66f4\u65e9\u63a5\u6536\u5230\u4e8b\u4ef6\uff0c\u5177\u4f53\u5143\u7d20\u5219\u6700\u540e\u63a5\u6536\u5230\u4e8b\u4ef6\u3002\u6bd4\u5982\u8bf4\u521a\u624d\u7684demo\uff0c\u5982\u679c\u662f\u4e8b\u4ef6\u6355\u83b7\u7684\u8bdd\uff0c\u4e8b\u4ef6\u53d1\u751f\u987a\u5e8f\u4f1a\u662f\u8fd9\u6837\u7684\uff1a\n<\/p>\n<ol style=\"color:#454545;background-color:#FFFFFF;font-family:\u5fae\u8f6f\u96c5\u9ed1, HelveticaNeue-Light, &quot;font-size:14px;vertical-align:baseline;\">\n<li style=\"font-weight:inherit;font-style:inherit;font-family:inherit;vertical-align:baseline;\">\n\t\twindow\n\t<\/li>\n<li style=\"font-weight:inherit;font-style:inherit;font-family:inherit;vertical-align:baseline;\">\n\t\tdocument\n\t<\/li>\n<li style=\"font-weight:inherit;font-style:inherit;font-family:inherit;vertical-align:baseline;\">\n\t\tbody\n\t<\/li>\n<li style=\"font-weight:inherit;font-style:inherit;font-family:inherit;vertical-align:baseline;\">\n\t\tbutton\n\t<\/li>\n<\/ol>\n<p style=\"font-size:16px;color:#4F4F4F;text-align:justify;background-color:#FFFFFF;font-family:\u5fae\u8f6f\u96c5\u9ed1, HelveticaNeue-Light, &quot;vertical-align:baseline;\">\n\t<a target=\"_blank\" href=\"http:\/\/www.daliane.com\/wp-content\/uploads\/2018\/02\/dom2.png\" class=\"fancy-ctn fancybox\"><img decoding=\"async\" src=\"http:\/\/www.daliane.com\/wp-content\/uploads\/2018\/02\/dom2.png\" title=\"\u4e8b\u4ef6\u6355\u83b7\u793a\u4f8b\u56fe\" alt=\"\" \/><\/a><br \/>\n\u5f53\u7136\uff0c\u7531\u4e8e\u65f6\u4ee3\u66f4\u8fed\uff0c\u4e8b\u4ef6\u5192\u6ce1\u65b9\u5f0f\u66f4\u80dc\u4e00\u7b79\u3002\u6240\u4ee5\u653e\u5fc3\u7684\u4f7f\u7528\u4e8b\u4ef6\u5192\u6ce1\uff0c\u6709\u7279\u6b8a\u9700\u8981\u518d\u4f7f\u7528\u4e8b\u4ef6\u6355\u83b7\u5373\u53ef\u3002\n<\/p>\n<h2 id=\"DOM\u4e8b\u4ef6\u6d41\" style=\"font-family:\u5fae\u8f6f\u96c5\u9ed1, HelveticaNeue-Light, &quot;font-weight:300;color:#574C4C;font-size:1.3em;background-color:#FFFFFF;vertical-align:baseline;\">\n\t<a name=\"t5\"><\/a><a target=\"_blank\" href=\"http:\/\/lxxyx.win\/2016\/02\/17\/%E5%AF%92%E5%81%87%E5%89%8D%E7%AB%AF%E5%AD%A6%E4%B9%A0(10)%E2%80%94%E2%80%94%E7%90%86%E8%A7%A3DOM%E4%BA%8B%E4%BB%B6%E6%B5%81%E7%9A%84%E4%B8%89%E4%B8%AA%E9%98%B6%E6%AE%B5\/#DOM%E4%BA%8B%E4%BB%B6%E6%B5%81\" class=\"headerlink\"><\/a>DOM\u4e8b\u4ef6\u6d41<br \/>\n<\/h2>\n<p style=\"font-size:16px;color:#4F4F4F;text-align:justify;background-color:#FFFFFF;font-family:\u5fae\u8f6f\u96c5\u9ed1, HelveticaNeue-Light, &quot;vertical-align:baseline;\">\n\tDOM\u4e8b\u4ef6\u6d41\u5305\u62ec\u4e09\u4e2a\u9636\u6bb5\u3002\n<\/p>\n<ol style=\"color:#454545;background-color:#FFFFFF;font-family:\u5fae\u8f6f\u96c5\u9ed1, HelveticaNeue-Light, &quot;font-size:14px;vertical-align:baseline;\">\n<li style=\"font-weight:inherit;font-style:inherit;font-family:inherit;vertical-align:baseline;\">\n\t\t\u4e8b\u4ef6\u6355\u83b7\u9636\u6bb5\n\t<\/li>\n<li style=\"font-weight:inherit;font-style:inherit;font-family:inherit;vertical-align:baseline;\">\n\t\t\u5904\u4e8e\u76ee\u6807\u9636\u6bb5\n\t<\/li>\n<li style=\"font-weight:inherit;font-style:inherit;font-family:inherit;vertical-align:baseline;\">\n\t\t\u4e8b\u4ef6\u5192\u6ce1\u9636\u6bb5\n\t<\/li>\n<\/ol>\n<p style=\"font-size:16px;color:#4F4F4F;text-align:justify;background-color:#FFFFFF;font-family:\u5fae\u8f6f\u96c5\u9ed1, HelveticaNeue-Light, &quot;vertical-align:baseline;\">\n\t\u5982\u56fe\u6240\u793a\uff08\u56fe\u7247\u6e90\u4e8e\u7f51\u7edc\uff0c\u82e5\u4fb5\u6743\u8bf7\u544a\u77e5\uff09\uff1a<br \/>\n<a target=\"_blank\" href=\"http:\/\/www.daliane.com\/wp-content\/uploads\/2018\/02\/dom3.png\" class=\"fancy-ctn fancybox\"><img decoding=\"async\" src=\"http:\/\/www.daliane.com\/wp-content\/uploads\/2018\/02\/dom3.png\" title=\"DOM\u4e8b\u4ef6\u6d41\u793a\u4f8b\u56fe\" alt=\"\" \/><\/a>\n<\/p>\n<h3 id=\"1-\u4e8b\u4ef6\u6355\u83b7\u9636\u6bb5\" style=\"font-family:\u5fae\u8f6f\u96c5\u9ed1, HelveticaNeue-Light, &quot;font-weight:300;color:#574C4C;font-size:1.1em;background-color:#FFFFFF;vertical-align:baseline;\">\n\t<a name=\"t6\"><\/a><a target=\"_blank\" href=\"http:\/\/lxxyx.win\/2016\/02\/17\/%E5%AF%92%E5%81%87%E5%89%8D%E7%AB%AF%E5%AD%A6%E4%B9%A0(10)%E2%80%94%E2%80%94%E7%90%86%E8%A7%A3DOM%E4%BA%8B%E4%BB%B6%E6%B5%81%E7%9A%84%E4%B8%89%E4%B8%AA%E9%98%B6%E6%AE%B5\/#1-%E4%BA%8B%E4%BB%B6%E6%8D%95%E8%8E%B7%E9%98%B6%E6%AE%B5\" class=\"headerlink\"><\/a>1. \u4e8b\u4ef6\u6355\u83b7\u9636\u6bb5<br \/>\n<\/h3>\n<p style=\"font-size:16px;color:#4F4F4F;text-align:justify;background-color:#FFFFFF;font-family:\u5fae\u8f6f\u96c5\u9ed1, HelveticaNeue-Light, &quot;vertical-align:baseline;\">\n\t\u4e5f\u5c31\u662f\u8bf4\uff0c\u5f53\u4e8b\u4ef6\u53d1\u751f\u65f6\uff0c\u9996\u5148\u53d1\u751f\u7684\u662f\u4e8b\u4ef6\u6355\u83b7\uff0c\u4e3a\u7236\u5143\u7d20\u622a\u83b7\u4e8b\u4ef6\u63d0\u4f9b\u4e86\u673a\u4f1a\u3002<br \/>\n\u4f8b\u5982\uff0c\u6211\u628a\u4e0a\u9762\u7684Demo\u4e2d\uff0cwindow\u70b9\u51fb\u4e8b\u4ef6\u66f4\u6539\u4e3a\u4f7f\u7528\u4e8b\u4ef6\u6355\u83b7\u6a21\u5f0f\u3002(addEventListener\u6700\u540e\u4e00\u4e2a\u53c2\u6570\uff0c<span style=\"font-weight:inherit;font-family:inherit;vertical-align:baseline;\">\u4e3atrue\u5219\u4ee3\u8868\u4f7f\u7528\u4e8b\u4ef6\u6355\u83b7\u6a21\u5f0f<\/span>\uff0cfalse\u5219\u8868\u793a\u4f7f\u7528\u4e8b\u4ef6\u5192\u6ce1\u6a21\u5f0f\u3002\u4e0d\u7406\u89e3\u7684\u53ef\u4ee5\u53bb\u5b66\u4e60\u4e00\u4e0baddEventListener\u51fd\u6570\u7684\u4f7f\u7528)\n<\/p>\n<table style=\"width:auto;margin:0px;color:#454545;font-family:inherit;font-size:16px;font-style:inherit;font-weight:inherit;background-color:#FFFFFF;padding:0px;border:none;\">\n<tbody>\n<tr>\n<td class=\"gutter\" style=\"border:none;font-size:16px;color:#4F4F4F;font-style:inherit;font-family:inherit;vertical-align:middle;\">\n<pre><\/pre>\n<\/td>\n<td class=\"code\" style=\"border:none;font-size:16px;color:#4F4F4F;font-style:inherit;font-family:inherit;vertical-align:middle;\">\n<pre>\r\n<\/pre>\n<pre class=\"prettyprint lang-js\">window.addEventListener('click', function() {\r\n  console.log('4. You click window');\r\n}, true);<\/pre>\n<p><\/p>\n<pre>\u6b64\u65f6\uff0c\u70b9\u51fbbutton\u7684\u6548\u679c\u662f\u8fd9\u6837\u7684\u3002<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p style=\"font-size:16px;color:#4F4F4F;text-align:justify;background-color:#FFFFFF;font-family:\u5fae\u8f6f\u96c5\u9ed1, HelveticaNeue-Light, &quot;vertical-align:baseline;\">\n\t<a target=\"_blank\" href=\"http:\/\/www.daliane.com\/wp-content\/uploads\/2018\/02\/dom4.png\" class=\"fancy-ctn fancybox\"><br \/>\n<img decoding=\"async\" src=\"http:\/\/www.daliane.com\/wp-content\/uploads\/2018\/02\/dom4.png\" title=\"DOM\u4e8b\u4ef6\u6d41\u4e2d\u4e8b\u4ef6\u6355\u83b7\u793a\u4f8b\u56fe\" alt=\"\" \/><\/a>\n<\/p>\n<p style=\"font-size:16px;color:#4F4F4F;text-align:justify;background-color:#FFFFFF;font-family:\u5fae\u8f6f\u96c5\u9ed1, HelveticaNeue-Light, &quot;vertical-align:baseline;\">\n\t\u53ef\u4ee5\u770b\u5230\uff0c\u70b9\u51fb\u4e8b\u4ef6\u5148\u88ab\u7236\u5143\u7d20\u622a\u83b7\u4e86\uff0c\u4e14\u8be5\u51fd\u6570\u53ea\u5728\u4e8b\u4ef6\u6355\u83b7\u9636\u6bb5\u8d77\u4f5c\u7528\u3002\n<\/p>\n<h3 id=\"\u5904\u4e8e\u76ee\u6807\u4e0e\u4e8b\u4ef6\u5192\u6ce1\u9636\u6bb5\" style=\"font-family:\u5fae\u8f6f\u96c5\u9ed1, HelveticaNeue-Light, &quot;font-weight:300;color:#574C4C;font-size:1.1em;background-color:#FFFFFF;vertical-align:baseline;\">\n\t<a name=\"t7\"><\/a><a target=\"_blank\" href=\"http:\/\/lxxyx.win\/2016\/02\/17\/%E5%AF%92%E5%81%87%E5%89%8D%E7%AB%AF%E5%AD%A6%E4%B9%A0(10)%E2%80%94%E2%80%94%E7%90%86%E8%A7%A3DOM%E4%BA%8B%E4%BB%B6%E6%B5%81%E7%9A%84%E4%B8%89%E4%B8%AA%E9%98%B6%E6%AE%B5\/#%E5%A4%84%E4%BA%8E%E7%9B%AE%E6%A0%87%E4%B8%8E%E4%BA%8B%E4%BB%B6%E5%86%92%E6%B3%A1%E9%98%B6%E6%AE%B5\" class=\"headerlink\"><\/a>\u5904\u4e8e\u76ee\u6807\u4e0e\u4e8b\u4ef6\u5192\u6ce1\u9636\u6bb5<br \/>\n<\/h3>\n<p style=\"font-size:16px;color:#4F4F4F;text-align:justify;background-color:#FFFFFF;font-family:\u5fae\u8f6f\u96c5\u9ed1, HelveticaNeue-Light, &quot;vertical-align:baseline;\">\n\t\u4e8b\u4ef6\u5230\u4e86\u5177\u4f53\u5143\u7d20\u65f6\uff0c\u5728\u5177\u4f53\u5143\u7d20\u4e0a\u53d1\u751f\uff0c\u5e76\u4e14\u88ab\u770b\u6210\u5192\u6ce1\u9636\u6bb5\u7684\u4e00\u90e8\u5206\u3002<br \/>\n\u968f\u540e\uff0c\u5192\u6ce1\u9636\u6bb5\u53d1\u751f\uff0c\u4e8b\u4ef6\u5f00\u59cb\u5192\u6ce1\u3002\n<\/p>\n<h3 id=\"\u963b\u6b62\u4e8b\u4ef6\u5192\u6ce1\" style=\"font-family:\u5fae\u8f6f\u96c5\u9ed1, HelveticaNeue-Light, &quot;font-weight:300;color:#574C4C;font-size:1.1em;background-color:#FFFFFF;vertical-align:baseline;\">\n\t<a name=\"t8\"><\/a><a target=\"_blank\" href=\"http:\/\/lxxyx.win\/2016\/02\/17\/%E5%AF%92%E5%81%87%E5%89%8D%E7%AB%AF%E5%AD%A6%E4%B9%A0(10)%E2%80%94%E2%80%94%E7%90%86%E8%A7%A3DOM%E4%BA%8B%E4%BB%B6%E6%B5%81%E7%9A%84%E4%B8%89%E4%B8%AA%E9%98%B6%E6%AE%B5\/#%E9%98%BB%E6%AD%A2%E4%BA%8B%E4%BB%B6%E5%86%92%E6%B3%A1\" class=\"headerlink\"><\/a>\u963b\u6b62\u4e8b\u4ef6\u5192\u6ce1<br \/>\n<\/h3>\n<p style=\"font-size:16px;color:#4F4F4F;text-align:justify;background-color:#FFFFFF;font-family:\u5fae\u8f6f\u96c5\u9ed1, HelveticaNeue-Light, &quot;vertical-align:baseline;\">\n\t\u4e8b\u4ef6\u5192\u6ce1\u8fc7\u7a0b\uff0c\u662f\u53ef\u4ee5\u88ab\u963b\u6b62\u7684\u3002\u9632\u6b62\u4e8b\u4ef6\u5192\u6ce1\u800c\u5e26\u6765\u4e0d\u5fc5\u8981\u7684\u9519\u8bef\u548c\u56f0\u6270\u3002<br \/>\n\u8fd9\u4e2a\u65b9\u6cd5\u5c31\u662f:stopPropagation()\n<\/p>\n<blockquote style=\"font-size:16px;color:#4F4F4F;font-family:\u5fae\u8f6f\u96c5\u9ed1, HelveticaNeue-Light, &quot;vertical-align:baseline;background:#F6F6F6;\">\n<p style=\"font-weight:inherit;text-align:justify;font-style:inherit;font-family:inherit;vertical-align:baseline;\">\n\t\tstopPropagation() \u65b9\u6cd5<br \/>\n\u7ec8\u6b62\u4e8b\u4ef6\u5728\u4f20\u64ad\u8fc7\u7a0b\u7684\u6355\u83b7\u3001\u76ee\u6807\u5904\u7406\u6216\u8d77\u6ce1\u9636\u6bb5\u8fdb\u4e00\u6b65\u4f20\u64ad\u3002\u8c03\u7528\u8be5\u65b9\u6cd5\u540e\uff0c\u8be5\u8282\u70b9\u4e0a\u5904\u7406\u8be5\u4e8b\u4ef6\u7684\u5904\u7406\u7a0b\u5e8f\u5c06\u88ab\u8c03\u7528\uff0c\u4e8b\u4ef6\u4e0d\u518d\u88ab\u5206\u6d3e\u5230\u5176\u4ed6\u8282\u70b9\u3002\n\t<\/p>\n<\/blockquote>\n<p style=\"font-size:16px;color:#4F4F4F;text-align:justify;background-color:#FFFFFF;font-family:\u5fae\u8f6f\u96c5\u9ed1, HelveticaNeue-Light, &quot;vertical-align:baseline;\">\n\t\u6211\u4eec\u5bf9button\u7684click\u4e8b\u4ef6\u505a\u4e00\u4e9b\u6539\u9020\u3002\n<\/p>\n<table style=\"width:auto;margin:0px;color:#454545;font-family:inherit;font-size:16px;font-style:inherit;font-weight:inherit;background-color:#FFFFFF;padding:0px;border:none;\">\n<tbody>\n<tr>\n<td class=\"gutter\" style=\"border:none;font-size:16px;color:#4F4F4F;font-style:inherit;font-family:inherit;vertical-align:middle;\">\n<pre><\/pre>\n<\/td>\n<td class=\"code\" style=\"border:none;font-size:16px;color:#4F4F4F;font-style:inherit;font-family:inherit;vertical-align:middle;\">\n<pre>\r\n<\/pre>\n<pre class=\"prettyprint lang-js\">button.addEventListener('click', function(event) {\r\n  \/\/ event\u4e3a\u4e8b\u4ef6\u5bf9\u8c61\r\n  console.log('1. You click Button');\r\n  event.stopPropagation();\r\n  console.log('Stop Propagation!');\r\n}, false);<\/pre>\n<p><\/p>\n<pre>\u70b9\u51fb\u540e\uff0c\u6548\u679c\u5982\u4e0b\u56fe\uff1a<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p style=\"font-size:16px;color:#4F4F4F;text-align:justify;background-color:#FFFFFF;font-family:\u5fae\u8f6f\u96c5\u9ed1, HelveticaNeue-Light, &quot;vertical-align:baseline;\">\n\t<a target=\"_blank\" href=\"http:\/\/www.daliane.com\/wp-content\/uploads\/2018\/02\/dom5.png\" class=\"fancy-ctn fancybox\"><br \/>\n<img decoding=\"async\" src=\"http:\/\/www.daliane.com\/wp-content\/uploads\/2018\/02\/dom5.png\" title=\"\u963b\u6b62\u5192\u6ce1\u793a\u4f8b\u56fe\" alt=\"\" \/><\/a>\n<\/p>\n<p style=\"font-size:16px;color:#4F4F4F;text-align:justify;background-color:#FFFFFF;font-family:\u5fae\u8f6f\u96c5\u9ed1, HelveticaNeue-Light, &quot;vertical-align:baseline;\">\n\t\u4e0d\u96be\u770b\u51fa\uff0c\u4e8b\u4ef6\u5728\u5230\u8fbe\u5177\u4f53\u5143\u7d20\u540e\uff0c\u505c\u6b62\u4e86\u5192\u6ce1\u3002\u4f46\u4e0d\u5f71\u54cd\u7236\u5143\u7d20\u7684\u4e8b\u4ef6\u6355\u83b7\u3002\n<\/p>\n<h2 id=\"\u603b\u7ed3\u4e0e\u611f\u60f3\" style=\"font-family:\u5fae\u8f6f\u96c5\u9ed1, HelveticaNeue-Light, &quot;font-weight:300;color:#574C4C;font-size:1.3em;background-color:#FFFFFF;vertical-align:baseline;\">\n\t<a name=\"t9\"><\/a><a target=\"_blank\" href=\"http:\/\/lxxyx.win\/2016\/02\/17\/%E5%AF%92%E5%81%87%E5%89%8D%E7%AB%AF%E5%AD%A6%E4%B9%A0(10)%E2%80%94%E2%80%94%E7%90%86%E8%A7%A3DOM%E4%BA%8B%E4%BB%B6%E6%B5%81%E7%9A%84%E4%B8%89%E4%B8%AA%E9%98%B6%E6%AE%B5\/#%E6%80%BB%E7%BB%93%E4%B8%8E%E6%84%9F%E6%83%B3\" class=\"headerlink\"><\/a>\u603b\u7ed3\u4e0e\u611f\u60f3<br \/>\n<\/h2>\n<p style=\"font-size:16px;color:#4F4F4F;text-align:justify;background-color:#FFFFFF;font-family:\u5fae\u8f6f\u96c5\u9ed1, HelveticaNeue-Light, &quot;vertical-align:baseline;\">\n\t\u4e8b\u4ef6\u6d41\uff1a\u63cf\u8ff0\u7684\u5c31\u662f\u4ece\u9875\u9762\u4e2d\u63a5\u53d7\u4e8b\u4ef6\u7684\u987a\u5e8f\u3002\u5206\u6709\u4e8b\u4ef6\u5192\u6ce1\u4e0e\u4e8b\u4ef6\u6355\u83b7\u4e24\u79cd\u3002<br \/>\nDOM\u4e8b\u4ef6\u6d41\u7684\u4e09\u4e2a\u9636\u6bb5\uff1a\n<\/p>\n<ol style=\"color:#454545;background-color:#FFFFFF;font-family:\u5fae\u8f6f\u96c5\u9ed1, HelveticaNeue-Light, &quot;font-size:14px;vertical-align:baseline;\">\n<li style=\"font-weight:inherit;font-style:inherit;font-family:inherit;vertical-align:baseline;\">\n\t\t\u4e8b\u4ef6\u6355\u83b7\u9636\u6bb5\n\t<\/li>\n<li style=\"font-weight:inherit;font-style:inherit;font-family:inherit;vertical-align:baseline;\">\n\t\t\u5904\u4e8e\u76ee\u6807\u9636\u6bb5\n\t<\/li>\n<li style=\"font-weight:inherit;font-style:inherit;font-family:inherit;vertical-align:baseline;\">\n\t\t\u4e8b\u4ef6\u5192\u6ce1\u9636\u6bb5\n\t<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>\u6d41 \u6d41\u7684\u6982\u5ff5\uff0c\u5728\u73b0\u4eca\u7684JavaScript\u4e2d\u968f\u5904\u53ef\u89c1\u3002\u6bd4\u5982\u8bf4React\u4e2d\u7684\u5355\u5411\u6570\u636e\u6d41\uff0cNode\u4e2d\u7684\u6d41\uff0c\u53c8\u6216\u662f\u4eca&#8230;<\/p>\n","protected":false},"author":2,"featured_media":228,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"footnotes":""},"categories":[83,38,60],"tags":[211],"_links":{"self":[{"href":"http:\/\/www.daliane.com\/category\/jinjiaoyou\/wp-json\/wp\/v2\/posts\/2999"}],"collection":[{"href":"http:\/\/www.daliane.com\/category\/jinjiaoyou\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.daliane.com\/category\/jinjiaoyou\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.daliane.com\/category\/jinjiaoyou\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/www.daliane.com\/category\/jinjiaoyou\/wp-json\/wp\/v2\/comments?post=2999"}],"version-history":[{"count":3,"href":"http:\/\/www.daliane.com\/category\/jinjiaoyou\/wp-json\/wp\/v2\/posts\/2999\/revisions"}],"predecessor-version":[{"id":3007,"href":"http:\/\/www.daliane.com\/category\/jinjiaoyou\/wp-json\/wp\/v2\/posts\/2999\/revisions\/3007"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/www.daliane.com\/category\/jinjiaoyou\/wp-json\/wp\/v2\/media\/228"}],"wp:attachment":[{"href":"http:\/\/www.daliane.com\/category\/jinjiaoyou\/wp-json\/wp\/v2\/media?parent=2999"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.daliane.com\/category\/jinjiaoyou\/wp-json\/wp\/v2\/categories?post=2999"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.daliane.com\/category\/jinjiaoyou\/wp-json\/wp\/v2\/tags?post=2999"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}