{"id":9165,"date":"2024-05-10T08:01:01","date_gmt":"2024-05-10T00:01:01","guid":{"rendered":""},"modified":"2024-05-10T08:01:01","modified_gmt":"2024-05-10T00:01:01","slug":"html\u5e95\u5c42\u5b9e\u73b0\u539f\u7406,javascript\u4e8b\u4ef6\u673a\u5236\u5e95\u5c42\u5b9e\u73b0\u7684\u539f\u7406","status":"publish","type":"post","link":"https:\/\/mushiming.com\/9165.html","title":{"rendered":"html\u5e95\u5c42\u5b9e\u73b0\u539f\u7406,javascript\u4e8b\u4ef6\u673a\u5236\u5e95\u5c42\u5b9e\u73b0\u7684\u539f\u7406"},"content":{"rendered":"
\n

\u53c8\u5230\u4e86\u626f\u6de1\u65f6\u95f4\u4e86\uff0c\u6211\u6700\u8fd1\u5728\u601d\u8003javascript\u4e8b\u4ef6\u673a\u5236\u5e95\u5c42\u7684\u5b9e\u73b0\uff0c\u4f46\u662f\u6682\u65f6\u6ca1\u6709\u52c7\u6c14\u53bb\u770bchrome\u6e90\u7801\uff0c\u6240\u4ee5\u4eca\u5929\u6211\u6765\u731c\u6d4b\u4e00\u628a<\/p>\n

\u6211\u4eec\u4eca\u5929\u6765\u731c\u4e00\u731c\uff0c\u63a2\u8ba8\u63a2\u8ba8\uff0cjavascript\u5e95\u5c42\u4e8b\u4ef6\u673a\u5236\u662f\u5982\u4f55\u5b9e\u73b0\u7684\u3002<\/p>\n

\u57fa\u7840\u77e5\u8bc6<\/p>\n

\u4e8b\u4ef6\u6355\u83b7\/\u5192\u6ce1<\/p>\n

\u6211\u4eec\u70b9\u51fb\u4e00\u4e2aspan\uff0c\u6211\u53ef\u80fd\u5c31\u60f3\u70b9\u51fb\u4e00\u4e2aspan\uff0c\u4e8b\u5b9e\u4e0a\u4ed6\u662f\u5148\u70b9\u51fbdocument\uff0c\u7136\u540e\u70b9\u51fb\u4e8b\u4ef6\u4f20\u9012\u5230span\u7684\uff0c\u800c\u4e14\u5e76\u4e0d\u4f1a\u5728span\u505c\u4e0b\uff0cspan\u6709\u5b50\u5143\u7d20\u5c31\u4f1a\u7ee7\u7eed\u5f80\u4e0b\uff0c\u6700\u540e\u4f1a\u4f9d\u6b21\u56de\u4f20\u81f3document\uff0c\u6211\u4eec\u8fd9\u91cc\u5077\u4e00\u5f20\u56fe\uff1a<\/p>\n

\"html\u5e95\u5c42\u5b9e\u73b0\u539f\u7406,javascript\u4e8b\u4ef6\u673a\u5236\u5e95\u5c42\u5b9e\u73b0\u7684\u539f\u7406<\/p>\n

\u6211\u4eec\u8fd9\u91cc\u5077\u4e86\u4e00\u5f20\u56fe\uff0c\u8fd9\u5f20\u56fe\u5f88\u597d\u7684\u8bf4\u660e\u4e86\u4e8b\u4ef6\u7684\u4f20\u64ad\u65b9\u5f0f\u4e8b\u4ef6\u5192\u6ce1\u5373\u7531\u6700\u5177\u4f53\u7684\u5143\u7d20(\u6587\u6863\u5d4c\u5957\u6700\u6df1\u8282\u70b9)\u63a5\u6536\uff0c\u7136\u540e\u9010\u6b65\u4e0a\u4f20\u81f3document\u4e8b\u4ef6\u6355\u83b7\u4f1a\u7531\u6700\u5148\u63a5\u6536\u5230\u4e8b\u4ef6\u7684\u5143\u7d20\u7136\u540e\u4f20\u5411\u6700\u91cc\u8fb9(\u6211\u4eec\u53ef\u4ee5\u5c06\u5143\u7d20\u60f3\u8c61\u6210\u4e00\u4e2a\u76d2\u5b50\u88c5\u4e00\u4e2a\u76d2\u5b50\uff0c\u800c\u4e0d\u662f\u4e00\u4e2a\u79ef\u6728\u5806\u79ef)<\/p>\n

\u8fd9\u91cc\u6211\u4eec\u8fdb\u5165dom\u4e8b\u4ef6\u6d41\uff0c\u8fd9\u91cc\u6211\u4eec\u8be6\u7ec6\u770b\u770bjavascript\u4e8b\u4ef6\u7684\u4f20\u9012\u65b9\u5f0f<\/p>\n

DOM\u4e8b\u4ef6\u6d41<\/p>\n

DOM2\u7ea7\u4e8b\u4ef6\u89c4\u5b9a\u4e8b\u4ef6\u5305\u62ec\u4e09\u4e2a\u9636\u6bb5\uff1a<\/p>\n

\u2460 \u4e8b\u4ef6\u6355\u83b7\u9636\u6bb5<\/p>\n

\u2461 \u5904\u4e8e\u76ee\u6807\u9636\u6bb5<\/p>\n

\u2462 \u4e8b\u4ef6\u5192\u6ce1\u9636\u6bb5<\/p>\n

\u4e8b\u4ef6\u5bf9\u8c61<\/p>\n

\u6240\u8c13\u4e8b\u4ef6\u5bf9\u8c61\uff0c\u662f\u4e0e\u7279\u5b9a\u5bf9\u8c61\u76f8\u5173\uff0c\u5e76\u4e14\u5305\u542b\u8be5\u4e8b\u4ef6\u8be6\u7ec6\u4fe1\u606f\u7684\u5bf9\u8c61\u3002<\/p>\n

\u4e8b\u4ef6\u5bf9\u8c61\u4f5c\u4e3a\u53c2\u6570\u4f20\u9012\u7ed9\u4e8b\u4ef6\u5904\u7406\u7a0b\u5e8f(IE8\u4e4b\u524d\u901a\u8fc7window.event\u83b7\u5f97)\uff0c\u6240\u6709\u4e8b\u4ef6\u5bf9\u8c61\u90fd\u6709\u4e8b\u4ef6\u7c7b\u578btype\u4e0e\u4e8b\u4ef6\u76ee\u6807target(IE8\u4e4b\u524d\u7684srcElement\u6211\u4eec\u4e0d\u5173\u6ce8\u4e86)<\/p>\n

\u5404\u4e2a\u4e8b\u4ef6\u7684\u4e8b\u4ef6\u53c2\u6570\u4e0d\u4e00\u6837\uff0c\u6bd4\u5982\u9f20\u6807\u4e8b\u4ef6\u5c31\u4f1a\u6709\u76f8\u5173\u5750\u6807\uff0c\u5305\u542b\u548c\u521b\u5efa\u4ed6\u7684\u7279\u5b9a\u4e8b\u4ef6\u6709\u5173\u7684\u5c5e\u6027\u548c\u65b9\u6cd5\uff0c\u89e6\u53d1\u7684\u4e8b\u4ef6\u4e0d\u4e00\u6837\uff0c\u53c2\u6570\u4e5f\u4e0d\u4e00\u6837(\u6bd4\u5982\u9f20\u6807\u4e8b\u4ef6\u5c31\u4f1a\u6709\u5750\u6807\u4fe1\u606f)\uff0c\u6211\u4eec\u8fd9\u91cc\u9898\u51e0\u4e2a\u8f83\u91cd\u8981\u7684<\/p>\n

PS\uff1a\u4ee5\u4e0b\u7684\u5144\u5f1f\u5168\u90e8\u662f\u53ea\u8bfb\u7684\uff0c\u6240\u4ee5\u4e0d\u8981\u5984\u60f3\u53bb\u968f\u610f\u66f4\u6539\uff0cIE\u4e4b\u524d\u7684\u95ee\u9898\u6211\u4eec\u5c31\u4e0d\u5173\u6ce8\u4e86<\/p>\n

bubbles<\/p>\n

\u8868\u660e\u4e8b\u4ef6\u662f\u5426\u5192\u6ce1<\/p>\n

cancelable<\/p>\n

\u8868\u660e\u662f\u5426\u53ef\u4ee5\u53d6\u6d88\u4e8b\u4ef6\u7684\u9ed8\u8ba4\u884c\u4e3a<\/p>\n

currentTarget<\/p>\n

\u67d0\u4e8b\u4ef6\u5904\u7406\u7a0b\u5e8f\u5f53\u524d\u6b63\u5728\u5904\u7406\u7684\u90a3\u4e2a\u5143\u7d20<\/p>\n

defaultPrevented<\/p>\n

\u4e3atrue\u8868\u660e\u5df2\u7ecf\u8c03\u7528\u4e86preventDefault(DOM3\u65b0\u589e)<\/p>\n

eventPhase<\/p>\n

\u8c03\u7528\u4e8b\u4ef6\u5904\u7406\u7a0b\u5e8f\u7684\u9636\u6bb5\uff1a1 \u6355\u83b7\uff1b2 \u5904\u4e8e\u9636\u6bb5\uff1b3 \u5192\u6ce1\u9636\u6bb5<\/p>\n

\u8fd9\u4e2a\u5c5e\u6027\u7684\u53d8\u5316\u9700\u8981\u5728\u65ad\u70b9\u4e2d\u67e5\u770b\uff0c\u4e0d\u7136\u4f60\u770b\u5230\u7684\u603b\u662f0<\/p>\n

target<\/p>\n

\u4e8b\u4ef6\u76ee\u6807(\u7ed1\u5b9a\u4e8b\u4ef6\u90a3\u4e2adom)<\/p>\n

trusted<\/p>\n

true\u8868\u660e\u662f\u7cfb\u7edf\u7684\uff0cfalse\u4e3a\u5f00\u53d1\u4eba\u5458\u81ea\u5b9a\u4e49\u7684(DOM3\u65b0\u589e)<\/p>\n

type<\/p>\n

\u4e8b\u4ef6\u7c7b\u578b<\/p>\n

view<\/p>\n

\u4e0e\u4e8b\u4ef6\u5173\u8054\u7684\u62bd\u8c61\u89c6\u56fe\uff0c\u53d1\u751f\u4e8b\u4ef6\u7684window\u5bf9\u8c61<\/p>\n

preventDefault<\/p>\n

\u53d6\u6d88\u4e8b\u4ef6\u9ed8\u8ba4\u884c\u4e3a\uff0ccancelable\u662ftrue\u65f6\u53ef\u4ee5\u4f7f\u7528<\/p>\n

stopPropagation<\/p>\n

\u53d6\u6d88\u4e8b\u4ef6\u6355\u83b7\/\u5192\u6ce1\uff0cbubbles\u4e3atrue\u624d\u80fd\u4f7f\u7528<\/p>\n

stopImmediatePropagation<\/p>\n

\u53d6\u6d88\u4e8b\u4ef6\u8fdb\u4e00\u6b65\u5192\u6ce1\uff0c\u5e76\u4e14\u7ec4\u7ec7\u4efb\u4f55\u4e8b\u4ef6\u5904\u7406\u7a0b\u5e8f\u88ab\u8c03\u7528(DOM3\u65b0\u589e)<\/p>\n

\u5728\u6211\u4eec\u7684\u4e8b\u4ef6\u5904\u7406\u5185\u90e8\uff0cthis\u4e0ecurrentTarget\u76f8\u540c<\/p>\n

\u6a21\u62dfjavascript\u4e8b\u4ef6\u673a\u5236<\/p>\n

\u5728\u6b64\u4e4b\u524d\uff0c\u6211\u4eec\u6765\u8bf4\u51e0\u4e2a\u57fa\u7840\u77e5\u8bc6\u70b9<\/p>\n

dom\u552f\u4e00\u6807\u8bc6<\/p>\n

\u5728\u9875\u9762\u4e0a\u7684dom\uff0c\u6bcf\u4e2adom\u90fd\u5e94\u8be5\u6709\u5176\u552f\u4e00\u6807\u8bc6\u2014\u2014_zid(\u6211\u4eec\u8fd9\u91cc\u7edf\u4e00\u4e3a_zid)\/sourceIndex\uff0c\u4f46\u662f\u591a\u6570\u6d4f\u89c8\u5668\u53ef\u80fd\u8ba4\u4e3a\uff0c\u8fd9\u4e2a\u63a5\u53e3\u5e76\u4e0d\u9700\u8981\u544a\u8bc9\u7528\u6237\u6240\u4ee5\u6211\u4eec\u90fd\u4e0d\u80fd\u83b7\u5f97<\/p>\n

\u4f46\u662fIE\u5c06\u8fd9\u4e2a\u63a5\u53e3\u653e\u51fa\u6765\u4e86\u2014\u2014sourceIndex<\/p>\n

\u6211\u4eec\u8fd9\u91cc\u4ee5\u767e\u5ea6\u9996\u9875\u4e3a\u4f8b\uff1a1 var doms = document.getElementsByTagName('*');<\/p>\n

2 var str = '';<\/p>\n

3 for (var i = 0, len = doms.length; i <\/p>\n

4     str += doms[i].tagName + ': ' + doms[i].sourceIndex + '\\n';<\/p>\n

5 }<\/p>\n

\"html\u5e95\u5c42\u5b9e\u73b0\u539f\u7406,javascript\u4e8b\u4ef6\u673a\u5236\u5e95\u5c42\u5b9e\u73b0\u7684\u539f\u7406<\/p>\n

\"html\u5e95\u5c42\u5b9e\u73b0\u539f\u7406,javascript\u4e8b\u4ef6\u673a\u5236\u5e95\u5c42\u5b9e\u73b0\u7684\u539f\u7406<\/p>\n

\u53ef\u4ee5\u770b\u5230\uff0c\u8d8a\u662f\u4e0a\u5c42\u7684_zid\u8d8a\u5c0f<\/p>\n

\u5176\u5b9e\uff0cdom _zid\u751f\u6210\u89c4\u5219\u5e94\u8be5\u662f\u4ee5\u6811\u7684\u6b63\u5e8f\u800c\u6765(\u597d\u50cf\u662f\u5427.....)\uff0c\u53cd\u6b63\u662f\u4ece\u4e0a\u5230\u4e0b\uff0c\u4ece\u5de6\u5230\u53f3<\/p>\n

\u6709\u4e86\u8fd9\u4e2a\u540e\uff0c\u6211\u4eec\u6765\u770b\u770b\u6211\u4eec\u5982\u4f55\u83b7\u5f97\u4e00\u4e2adom\u7684\u6ce8\u518c\u4e8b\u4ef6\u96c6\u5408<\/p>\n

\u83b7\u53d6dom\u6ce8\u518c\u4e8b\u4ef6\u96c6\u5408<\/p>\n

\u6bd4\u5982\u6211\u4eec\u4e3a\u4e00\u4e2adom\u540c\u65f6\u7ed1\u5b9a\u4e862\u4e2aclick\u4e8b\u4ef6\uff0c\u53c8\u7ed9\u4ed6\u7ed1\u5b9a\u4e00\u4e2akeydown\u4e8b\u4ef6\uff0c\u90a3\u4e48\u5bf9\u4e8e\u8fd9\u4e2adom\u6765\u8bf4\u4ed6\u5c31\u5177\u67093\u4e2a\u4e8b\u4ef6\u4e86<\/p>\n

\u6211\u4eec\u6709\u4ec0\u4e48\u529e\u6cd5\u53ef\u4ee5\u83b7\u5f97\u4e00\u4e2adom\u6ce8\u518c\u7684\u4e8b\u4ef6\u5462\uff1f\uff1f\uff1f<\/p>\n

\u7b54\u6848\u5f88\u9057\u61be\uff0c\u6d4f\u89c8\u5668\u90fd\u6ca1\u6709\u653e\u51faapi\uff0c\u6240\u4ee5\u6211\u4eec\u6682\u65f6\u4e0d\u80fd\u77e5\u9053\u4e00\u4e2adom\u5230\u5e95\u88ab\u6ce8\u518c\u4e86\u591a\u5c11\u4e8b\u4ef6......<\/p>\n

PS\uff1a\u5982\u679c\u60a8\u77e5\u9053\u8fd9\u4e2a\u95ee\u9898\u7684\u7b54\u6848\uff0c\u8bf7\u7559\u8a00<\/p>\n

\u6709\u4e86\u4ee5\u4e0a\u4e24\u4e2a\u77e5\u8bc6\u70b9\uff0c\u6211\u4eec\u5c31\u53ef\u4ee5\u5f00\u59cb\u4eca\u5929\u7684\u626f\u6de1\u4e86<\/p>\n

\u6ce8\u610f\uff1a\u4e0b\u6587\u8fdb\u5165\u731c\u60f3\u65f6\u95f4<\/p>\n

\u8865\u5145\u70b9<\/p>\n

\u8fd9\u91cc\u901a\u8fc7\u7f51\u53cb\u7684\u63d0\u793a\uff0c\u5176\u5b9e\u4e00\u4e9b\u6d4f\u89c8\u5668\u662f\u63d0\u4f9b\u4e86\u83b7\u53d6dom\u4e8b\u4ef6\u8282\u70b9\u7684\u65b9\u6cd5\u7684<\/p>\n

DOM API\u662f\u6ca1\u6709\u3002\u4e0d\u8fc7\u6d4f\u89c8\u5668\u63d0\u4f9b\u4e86\u4e00\u4e2a\u8c03\u8bd5\u7528\u7684\u63a5\u53e3\u3002<\/p>\n

Chrome\u5728console\u4e0b\u53ef\u4ee5\u8fd0\u884c\u4e0b\u9762\u8fd9\u4e2a\u65b9\u6cd5\uff1a<\/p>\n

getEventListeners(node)\uff0c<\/p>\n

\u83b7\u5f97\u5bf9\u8c61\u4e0a\u7ed1\u5b9a\u7684\u6240\u6709\u4e8b\u4ef6\u76d1\u542c\u51fd\u6570\u3002<\/p>\n

\u6ce8\u610f\uff0c\u662f\u5728console\u91cc\u9762\u6267\u884cgetEventListeners\u65b9\u6cd51 <\/p>\n

2 <\/p>\n

3   <\/p>\n

4 <\/p>\n

5 <\/p>\n

6 <\/p>\n

\n ddssdsd\n <\/div>\n

7   <\/p>\n

8     var node = document.getElementsByTagName('*');<\/p>\n

9     var d = document.getElementById('d');<\/p>\n

10     d.addEventListener('click', function () {
\n <\/p>\n

11       alert();<\/p>\n

12     }, false);<\/p>\n

13     d.addEventListener('click', function () {
\n <\/p>\n

14       alert('\u6211\u662f\u7b2c\u4e8c\u6b21');<\/p>\n

15     }, false);<\/p>\n

16     d.onclick = function () {
\n <\/p>\n

17       alert('\u4e0d\u89c4\u8303\u7684\u7ed1\u5b9a');<\/p>\n

18     }<\/p>\n

19     d.addEventListener('click', function () {
\n <\/p>\n

20       alert();<\/p>\n

21     }, true);<\/p>\n

22<\/p>\n

23     d.addEventListener('mousedown', function () {
\n <\/p>\n

24       console.log('mousedown');<\/p>\n

25     }, true);<\/p>\n

26     var evets = typeof getEventListeners == 'function' && getEventListeners(d)<\/p>\n

27   <\/p>\n

28 <\/p>\n

29 <\/p>\n

\u4ee5\u4e0a\u4ee3\u7801\u5728chrome\u4e2d\u7684console\u7ed3\u679c\u4e3a\uff1a<\/p>\n

\"html\u5e95\u5c42\u5b9e\u73b0\u539f\u7406,javascript\u4e8b\u4ef6\u673a\u5236\u5e95\u5c42\u5b9e\u73b0\u7684\u539f\u7406<\/p>\n

\u53ef\u4ee5\u770b\u5230\uff0c\u65e0\u8bba\u4f55\u79cd\u7ed1\u5b9a\uff0c\u8fd9\u91cc\u90fd\u662f\u53ef\u4ee5\u83b7\u53d6\u7684\uff0c\u800c\u4e14\u83b7\u53d6\u7684\u5bf9\u8c61\u4e0e\u6211\u4eec\u6a21\u62df\u7684\u5bf9\u8c61\u6bd4\u8f83\u63a5\u8fd1<\/p>\n

\u4e8b\u4ef6\u6ce8\u518c\u53d1\u751f\u7684\u4e8b<\/p>\n

\u9996\u5148\uff0c\u6211\u4eec\u4e3adom\u6ce8\u518c\u4e8b\u4ef6\u7684\u8bed\u6cd5\u662f\uff1a1 dom.addEventListener('click', function () {
\n <\/p>\n

2     alert('ddd');<\/p>\n

3 })<\/p>\n

\u4ee5\u4e0a\u8ff0\u4ee3\u7801\u6765\u8bf4\uff0c\u6211\u4f5c\u4e3a\u6d4f\u89c8\u5668\uff0c\u4ee5\u8fd9\u4e2a\u4ee3\u7801\u6765\u8bf4\uff0c\u5728\u6ce8\u518c\u9636\u6bb5\u6211\u4fbf\u53ef\u4ee5\u4fdd\u5b58\u4ee5\u4e0b\u4fe1\u606f\uff1a<\/p>\n

1 <\/p>\n

2 <\/p>\n

3     <\/p>\n

4     <\/p>\n

5          #p { width: 300px; height: 300px; padding: 10px;  border: 1px solid black; }<\/p>\n

6          #c { width: 100px; height: 100px; border: 1px solid red; }<\/p>\n

7     <\/p>\n

8 <\/p>\n

9 <\/p>\n

10     <\/p>\n

\n

11         parent<\/p>\n

12         <\/p>\n

\n

13             child<\/p>\n

14         <\/p>\n<\/p><\/div>\n

15     <\/p>\n<\/p><\/div>\n

16     <\/p>\n

17         var p = document.getElementById('p'),<\/p>\n

18         c = document.getElementById('c');<\/p>\n

19         c.addEventListener('click', function () {
\n <\/p>\n

20             alert('\u5b50\u8282\u70b9\u6355\u83b7')<\/p>\n

21         }, true);<\/p>\n

22<\/p>\n

23         c.addEventListener('click', function () {
\n <\/p>\n

24             alert('\u5b50\u8282\u70b9\u5192\u6ce1')<\/p>\n

25         }, false);<\/p>\n

26<\/p>\n

27         p.addEventListener('click', function () {
\n <\/p>\n

28             alert('\u7236\u8282\u70b9\u6355\u83b7')<\/p>\n

29         }, true);<\/p>\n

30<\/p>\n

31         p.addEventListener('click', function () {
\n <\/p>\n

32             alert('\u7236\u8282\u70b9\u5192\u6ce1')<\/p>\n

33         }, false);<\/p>\n

34     <\/p>\n

35 <\/p>\n

36 <\/p>\n

\"html\u5e95\u5c42\u5b9e\u73b0\u539f\u7406,javascript\u4e8b\u4ef6\u673a\u5236\u5e95\u5c42\u5b9e\u73b0\u7684\u539f\u7406<\/p>\n

\u8fd9\u91cc\uff0c\u6211\u4eec\u4e3aparent\u548cchild\u7ed1\u5b9a\u4e86click\u4e8b\u4ef6\uff0c\u6240\u4ee5\u6d4f\u89c8\u5668\u53ef\u4ee5\u83b7\u5f97\u5982\u4e0b\u961f\u5217\u7ed3\u6784\uff1a<\/p>\n

1 \/****** \u7b2c\u4e00\u6b65-\u6ce8\u518c\u4e8b\u4ef6 ******\/<\/p>\n

2 \/\/\u9875\u9762\u4e8b\u4ef6\u5b58\u50a8\u5728\u4e00\u4e2a\u961f\u5217\u91cc<\/p>\n

3 \/\/\u4ee5_zid\u6392\u5e8f<\/p>\n

4 var eventQueue = [<\/p>\n

5   {
\n <\/p>\n

6     _zid: 'parent',<\/p>\n

7     handlers: {
\n <\/p>\n

8       click: {
\n <\/p>\n

9         captrue: [fn, fn],<\/p>\n

10         bubble: [fn, fn]<\/p>\n

11       }<\/p>\n

12     }<\/p>\n

13   },<\/p>\n

14   {
\n <\/p>\n

15     _zid:'child',<\/p>\n

16     handlers:{
\n <\/p>\n

17       click: {
\n <\/p>\n

18         captrue: [],<\/p>\n

19         bubble: []<\/p>\n

20       }<\/p>\n

21     }<\/p>\n

22   },<\/p>\n

23   {
\n <\/p>\n

24     _zid: '_zid',<\/p>\n

25     handlers: {
\n <\/p>\n

26     \/\/\u2026\u2026<\/p>\n

27     }<\/p>\n

28   }<\/p>\n

29 ];<\/p>\n

\u5c31\u90a3parent\u8fd9\u4e2adiv\u6765\u8bf4\uff0c\u6211\u4eec\u4e3a\u4ed6\u7ed1\u5b9a\u4e86\u4e24\u4e2aclick\u4e8b\u4ef6(\u6211\u4eec\u5176\u5b9e\u53ef\u4ee5\u7ed1\u5b9a3\u4e2a4\u4e2a\u6216\u8005\u66f4\u591a\uff0c\u6240\u4ee5\u4e8b\u4ef6\u96c6\u5408\u662f\u4e00\u4e2a\u6570\u7ec4\uff0c\u6267\u884c\u5177\u6709\u5148\u540e\u987a\u5e8f)<\/p>\n

\u5176\u4e2d\u6ce8\u518c\u4e8b\u4ef6\u65f6\u5019\uff0c\u53c8\u4f1a\u5206\u5192\u6ce1\u548c\u6355\u83b7\uff0c\u800c\u4e14\u8fd9\u91cc\u4ee5_zid\u6392\u5e8f(\u6bd4\u5982\uff1adocument->body->div#p->div#c)<\/p>\n

\u7136\u540e\u7b2c\u4e00\u4e2a\u9636\u6bb5\u5c31\u7ed3\u675f\u4e86<\/p>\n

PS\uff1a\u6211\u60f3\u5e95\u5c42c++\u8bed\u8a00\u4e00\u5b9a\u6709\u7c7b\u4f3c\u7684\u8fd9\u4e2a\u961f\u5217\uff0c\u800c\u4e14\u53ef\u4ee5\u91ca\u653e\u63a5\u53e3\uff0c\u8ba9\u6211\u4eec\u83b7\u53d6\u4e00\u4e2adom\u6240\u6ce8\u518c\u7684\u6240\u6709\u4e8b\u4ef6<\/p>\n

\u6ce8\u610f\uff0c\u6b64\u5904\u961f\u5217\u662f\u8fd9\u6837\uff0c\u4f46\u662f\u6211\u4eec\u771f\u6b63\u70b9\u51fb\u4e00\u4e2a\u5143\u7d20\uff0c\u53ef\u80fd\u5c31\u53ea\u62bd\u53d6\u5176\u4e2d\u4e00\u90e8\u5206\u5173\u8054\u7684\u5bf9\u8c61\u7ec4\u6210\u4e00\u4e2a\u65b0\u7684\u961f\u5217\uff0c\u4f9b\u4e0b\u9762\u4f7f\u7528<\/p>\n

\u521d\u59cb\u5316\u4e8b\u4ef6\u53c2\u6570<\/p>\n

\u7b2c\u4e8c\u6b65\u5c31\u662f\u521d\u59cb\u5316\u4e8b\u4ef6\u53c2\u6570\uff0c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7addEventListener\uff0c\u521b\u5efa\u4e8b\u4ef6\u53c2\u6570\uff0c\u4f46\u662f\u6211\u4eec\u8fd9\u91cc\u7b80\u5355\u6a21\u62df\u5373\u53ef\uff1a<\/p>\n

\u6ce8\u610f\uff0c\u4e3a\u4e86\u65b9\u4fbf\u7406\u89e3\uff0c\u6211\u4eec\u8fd9\u91cc\u6682\u4e0d\u8003\u8651mousedown1 \/****** \u7b2c\u4e8c\u6b65-\u521d\u59cb\u5316\u4e8b\u4ef6\u53c2\u6570 ******\/<\/p>\n

2 var Event = {};<\/p>\n

3 Event.type = 'click';<\/p>\n

4 Event.target = el;\/\/\u5f53\u524d\u624b\u6307\u70b9\u51fb\u6700\u6df1dom\u5143\u7d20<\/p>\n

5 \/\/\u521d\u59cb\u5316\u4fe1\u606f<\/p>\n

6 \/\/......<\/p>\n

7 \/\/\u9f20\u6807\u4f4d\u7f6e\u4fe1\u606f\u7b49<\/p>\n

\u5728\u8fd9\u91cc\u6bd4\u8f83\u5173\u952e\u7684\u5c31\u662f\u6211\u4eec\u4e00\u5b9a\u8981\u597d\u597d\u5b9a\u4e49\u6211\u4eec\u7684target\uff01\uff01\uff01<\/p>\n

\u4e8e\u662f\u53ef\u4ee5\u8fdb\u5165\u6211\u4eec\u7684\u5173\u952e\u6b65\u9aa4\u4e86\uff0c\u89e6\u53d1\u4e8b\u4ef6<\/p>\n

\u89e6\u53d1\u4e8b\u4ef6<\/p>\n

\u4e8b\u4ef6\u89e6\u53d1\u5206\u4e09\u6b65\u8d70\uff0c\u9996\u5148\u662f\u6355\u83b7\u7136\u540e\u662f\u5904\u4e8e\u9636\u6bb5\u6700\u540e\u662f\u5192\u6ce1\u9636\u6bb5\uff1a1 \/****** \u7b2c\u4e09\u6b65-\u89e6\u53d1\u4e8b\u4ef6 ******\/<\/p>\n

2 var isTarget = false;<\/p>\n

3 Event.eventPhase = 1;<\/p>\n

4 \/\/\u9996\u5148\u662f\u6355\u83b7\u9636\u6bb5\uff0c\u4e8b\u4ef6\u6267\u884c\u81f3event.target\u4e3a\u6b62\uff0c\u6211\u4eec\u8fd9\u91cc\u53ea\u5173\u6ce8click<\/p>\n

5 for (var index = 0, length = eventQueue.lenth; index <\/p>\n

6   \/\/\u83b7\u53d6\u6355\u83b7\u65f6\u671f\u8be5\u5143\u7d20\u7684click\u4e8b\u4ef6\u96c6\u5408<\/p>\n

7   var clickHandlers = eventQueue[index].handlers.click.captrue;<\/p>\n

8   for (var i = 0, len = clickHandlers.length; i <\/p>\n

9     Event.currentTarget = clickHandlers[i]; \/\/\u4e8b\u4ef6\u5904\u7406\u7a0b\u5e8f\u5f53\u524d\u6b63\u5728\u5904\u7406\u7684\u90a3\u4e2a\u5143\u7d20<\/p>\n

10     \/\/\u6267\u884c\u81f3target\u4fbf\u8df3\u51fa\u5faa\u73af\uff0c\u4e0d\u518d\u6267\u884c\u4e0b\u9762\u7684\u64cd\u4f5c<\/p>\n

11     if (Event.target._zid == eventQueue[index]._zid) {
\n <\/p>\n

12       Event.eventPhase = 2;\/\/\u5f53\u524d\u9636\u6bb5<\/p>\n

13       isTarget = true;<\/p>\n

14     }<\/p>\n

15     \/\/\u6267\u884c\u7ed1\u5b9a\u4e8b\u4ef6<\/p>\n

16     clickHandlers[i](Event);<\/p>\n

17     \/\/\u5982\u679c\u963b\u6b62\u5192\u6ce1\uff0c\u8df3\u51fa\u6240\u6709\u5faa\u73af\uff0c\u4e0d\u6267\u884c\u540e\u9762\u7684\u4e8b\u4ef6<\/p>\n

18     if (Event.bubbles) {
\n <\/p>\n

19       return;<\/p>\n

20     }<\/p>\n

21   }<\/p>\n

22   \/\/\u82e5\u662f\u5f53\u524d\u5df2\u7ecf\u662ftarget\u4fbf\u4e0d\u518d\u5411\u4e0b\u6355\u83b7<\/p>\n

23   if(isTarget) break;<\/p>\n

24 }<\/p>\n

25 Event.eventPhase = 3;<\/p>\n

26 \/\/\u5192\u6ce1\u9636\u6bb5<\/p>\n

27 for(var index = eventQueue.lenth; index !=0; index--) {
\n <\/p>\n

28   \/\/\u5982\u679czid\u5c0f\u4e8e\u7b49\u4e8e\u5f53\u524d\u5143\u7d20\uff0c\u8bf4\u660e\u4e0d\u9700\u8981\u5904\u7406<\/p>\n

29   if(eventQueue[index]._zid <= Event.target._zid) continue;<\/p>\n

30   \/\/\u9700\u8981\u5904\u7406\u7684\u90e8\u5206\u4e86<\/p>\n

31   var clickHandlers = eventQueue[index].handlers.click.bubble;<\/p>\n

32<\/p>\n

33   \/\/\u6b64\u6bb5\u4ee3\u7801\u53ef\u4ee5\u91cd\u6784\uff0c\u6682\u65f6\u4e0d\u7ba1<\/p>\n

34   for (var i = 0, len = clickHandlers.length; i <\/p>\n

35     Event.currentTarget = clickHandlers[i]; \/\/\u4e8b\u4ef6\u5904\u7406\u7a0b\u5e8f\u5f53\u524d\u6b63\u5728\u5904\u7406\u7684\u90a3\u4e2a\u5143\u7d20<\/p>\n

36     \/\/\u6267\u884c\u7ed1\u5b9a\u4e8b\u4ef6<\/p>\n

37     clickHandlers[i](Event);<\/p>\n

38     \/\/\u5982\u679c\u963b\u6b62\u5192\u6ce1\uff0c\u8df3\u51fa\u6240\u6709\u5faa\u73af\uff0c\u4e0d\u6267\u884c\u540e\u9762\u7684\u4e8b\u4ef6<\/p>\n

39     if (Event.bubbles) {
\n <\/p>\n

40       return;<\/p>\n

41     }<\/p>\n

42   }<\/p>\n

43 }<\/p>\n

\u8fd9\u4e2a\u6ce8\u91ca\u5199\u7684\u5f88\u6e05\u695a\u4e86\u5e94\u8be5\u80fd\u8868\u8fbe\u6e05\u695a\u6211\u7684\u610f\u601d\uff0c\u4e8e\u662f\u6211\u4eec\u8fd9\u91cc\u5c31\u7b80\u5355\u7684\u6a21\u62df\u4e86\u4e8b\u4ef6\u673a\u5236\u7684\u5e95\u5c42\u539f\u7406\u4e86\uff1a)<\/p>\n

PS\uff1a\u5982\u679c\u60a8\u89c9\u5f97\u4e0d\u5bf9\uff0c\u8bf7\u7559\u8a00<\/p>\n

\u9a8c\u8bc1\u731c\u60f3<\/p>\n

\u73b0\u5728\uff0c\u57fa\u7840\u7406\u8bba\u63d0\u51fa\u6765\u4e86\uff0c\u6211\u4eec\u9700\u8981\u9a8c\u8bc1\u4e0b\u8fd9\u4e2a\u60f3\u6cd5\u662f\u5426\u7ad9\u5f97\u4f4f\u811a\uff0c\u6240\u4ee5\u8fd9\u91cc\u63d0\u4e86\u51e0\u4e2a\u4f8b\u5b50\uff0c\u9996\u5148\u6211\u4eec\u56de\u5230\u4e0a\u9762\u7684\u95ee\u9898\u5427<\/p>\n

\u9a8c\u8bc1\u4e00\uff1a\u70b9\u51fb\u95ee\u9898<\/p>\n

\u9996\u5148\u6211\u4eec\u6765\u770b\u8fd9\u4e2a\u95ee\u9898\uff0c\u6211\u4eec\u5206\u522b\u4e3aparent\u4e0echild\u6ce8\u518c\u4e86\u4e24\u4e2aclick\u4e8b\u4ef6\uff0c\u4e00\u6b21\u5192\u6ce1\u4e00\u6b21\u6355\u83b7<\/p>\n

\u5f53\u6211\u4eec\u70b9\u51fb\u7236\u5143\u7d20\u65f6\uff0c\u6211\u4eec\u6309\u7167\u7406\u8bba\u7684\u6267\u884c\u903b\u8f91\u5982\u4e0b\uff1a<\/p>\n

\u5f00\u59cb\u904d\u5386\u4e8b\u4ef6\u961f\u5217(\u7531document\u5f00\u59cb)<\/p>\n

\u5f53\u904d\u5386\u5bf9\u8c61\u5982\u679c\u6ce8\u518c\u4e86click\u4e8b\u4ef6\u5c31\u4f1a\u89e6\u53d1\uff0c\u5982\u679c\u963b\u6b62\u4e86\u5192\u6ce1\uff0c\u6267\u884c\u540e\u4fbf\u8df3\u51fa\u5faa\u73af\u4e0d\u518d\u6267\u884c<\/p>\n

\u56e0\u4e3a\u4e4b\u524d\u5e76\u6ca1\u6709\u6ce8\u518c\u4e8b\u4ef6\uff0c\u6240\u4ee5\u76f4\u63a5\u5230\u4e86parent\uff0c\u8fd9\u91cc\u53d1\u73b0parent\u7684_zid\u4e0etarget\u7684_zid\u76f8\u7b49<\/p>\n

\u4e8e\u662f\u4fbf\u5c06\u72b6\u6001\u7f6e\u4e3a\u5904\u4e8e\u76ee\u6807\u9636\u6bb5\uff0c\u5e76\u6253\u4e0a\u6807\u8bb0\u8df3\u51fa\u6355\u83b7\u5faa\u73af\uff0c\u4e0d\u518d\u6267\u884c\u540e\u9762\u7684\u4e8b\u4ef6\u53e5\u67c4Event.eventPhase = 2;\/\/\u5f53\u524d\u9636\u6bb5<\/p>\n

isTarget = true;<\/p>\n

\u6355\u83b7\u7ed3\u675f\u540e\uff0c\u5f00\u59cb\u6267\u884c\u5192\u6ce1\u7684\u4e8b\u4ef6\uff0c\u5faa\u73af\u7531\u540e\u5411\u524d\uff0c\u5f00\u59cb\u662fchild\u7684click\u4e8b\u4ef6\uff0c\u4f46\u662f\u6b64\u65f6child\u7684_zid\u5927\u4e8etarget\u7684_zid\u6240\u4ee5\u7ee7\u7eed\u5faa\u73af<\/p>\n

\u6700\u540e\u4f1a\u6267\u884cparent\u4ee5\u4e0a\u7684dom\u6ce8\u518c\u7684click\u4e8b\u4ef6\uff0c\u6ca1\u6709\u5c31\u7b97\u4e86<\/p>\n

\u81f3\u4e8e\u70b9\u51fbchild\u7684\u903b\u8f91\u6211\u4eec\u8fd9\u91cc\u5c31\u4e0d\u5206\u6790\u4e86<\/p>\n

\u9a8c\u8bc1\u4e8c\uff1a\u7a81\u7136\u79fb\u9664dom<\/p>\n

\u6211\u4eec\u8fd9\u91cc\u5bf9\u4e0a\u9898\u505a\u4e00\u4e2a\u53d8\u5f62\uff0c\u6211\u4eec\u5728parent\u70b9\u51fb\u65f6\u5019(\u6355\u83b7\u9636\u6bb5)\u5c06child div\u7ed9\u5220\u9664\uff0c\u770b\u770b\u6709\u4ec0\u4e48\u60c5\u51b5<\/p>\n

1 <\/p>\n

2 <\/p>\n

3     <\/p>\n

4     <\/p>\n

5          #p { width: 300px; height: 300px; padding: 10px;  border: 1px solid black; }<\/p>\n

6          #c { width: 100px; height: 100px; border: 1px solid red; }<\/p>\n

7     <\/p>\n

8 <\/p>\n

9 <\/p>\n

10     <\/p>\n

\n

11         parent<\/p>\n

12         <\/p>\n

\n

13             child<\/p>\n

14         <\/p>\n<\/p><\/div>\n

15     <\/p>\n<\/p><\/div>\n

16     <\/p>\n

17         var p = document.getElementById('p'),<\/p>\n

18         c = document.getElementById('c');<\/p>\n

19         c.addEventListener('click', function () {
\n <\/p>\n

20             alert('\u5b50\u8282\u70b9\u6355\u83b7')<\/p>\n

21         }, true);<\/p>\n

22<\/p>\n

23         c.addEventListener('click', function () {
\n <\/p>\n

24             alert('\u5b50\u8282\u70b9\u5192\u6ce1')<\/p>\n

25         }, false);<\/p>\n

26<\/p>\n

27         p.addEventListener('click', function () {
\n <\/p>\n

28             alert('\u7236\u8282\u70b9\u6355\u83b7')<\/p>\n

29             p.removeChild(c);<\/p>\n

30         }, true);<\/p>\n

31<\/p>\n

32         p.addEventListener('click', function () {
\n <\/p>\n

33             alert('\u7236\u8282\u70b9\u5192\u6ce1')<\/p>\n

34         }, false);<\/p>\n

35     <\/p>\n

36 <\/p>\n

37 <\/p>\n

\u5176\u5b9e\u8fd9\u91cc\u8fd8\u6709\u4e00\u4e2a\u4f18\u5316\u70b9\uff0c\u76f8\u4fe1\u5927\u5bb6\u90fd\u77e5\u9053\uff1a\u79fb\u9664dom\u5e76\u4e0d\u4f1a\u79fb\u9664\u4e8b\u4ef6\u53e5\u67c4\uff0c\u8fd9\u4e2a\u5fc5\u987b\u624b\u52a8\u91ca\u653e<\/p>\n

\u5c31\u662f\u56e0\u4e3a\u8fd9\u4e2a\u539f\u56e0\uff0c\u6211\u4eec\u7684\u6574\u4e2a\u903b\u8f91\u4ecd\u7136\u4f1a\u6267\u884c\uff0c\u5404\u4f4d\u81ea\u5df1\u53ef\u4ee5\u8bd5\u8bd5<\/p>\n

\u9a8c\u8bc1\u4e09\uff1achild\u963b\u6b62\u5192\u6ce1<\/p>\n

\u6211\u4eec\u8fd9\u91cc\u518d\u5c06\u4e0a\u9898\u7a0d\u52a0\u53d8\u5f62\uff0c\u5728child \u5192\u6ce1\u9636\u6bb5\u7ec4\u7ec7\u5192\u6ce1\uff0c\u5176\u5b9e\u8fd9\u4e2a\u4e0d\u7528\u8bf4\uff0cparent\u7684click\u4e0d\u4f1a\u6267\u884c<\/p>\n

1 <\/p>\n

2 <\/p>\n

3     <\/p>\n

4     <\/p>\n

5          #p { width: 300px; height: 300px; padding: 10px;  border: 1px solid black; }<\/p>\n

6          #c { width: 100px; height: 100px; border: 1px solid red; }<\/p>\n

7     <\/p>\n

8 <\/p>\n

9 <\/p>\n

10     <\/p>\n

\n

11         parent<\/p>\n

12         <\/p>\n

\n

13             child<\/p>\n

14         <\/p>\n<\/p><\/div>\n

15     <\/p>\n<\/p><\/div>\n

16     <\/p>\n

17         var p = document.getElementById('p'),<\/p>\n

18         c = document.getElementById('c');<\/p>\n

19         c.addEventListener('click', function () {
\n <\/p>\n

20             alert('\u5b50\u8282\u70b9\u6355\u83b7')<\/p>\n

21         }, true);<\/p>\n

22<\/p>\n

23         c.addEventListener('click', function (e) {
\n <\/p>\n

24             alert('\u5b50\u8282\u70b9\u5192\u6ce1')<\/p>\n

25             e.stopPropagation();<\/p>\n

26         }, false);<\/p>\n

27<\/p>\n

28         p.addEventListener('click', function () {
\n <\/p>\n

29             alert('\u7236\u8282\u70b9\u6355\u83b7')<\/p>\n

30         }, true);<\/p>\n

31<\/p>\n

32         p.addEventListener('click', function () {
\n <\/p>\n

33             alert('\u7236\u8282\u70b9\u5192\u6ce1')<\/p>\n

34         }, false);<\/p>\n

35     <\/p>\n

36 <\/p>\n

37 <\/p>\n

\u9a8c\u8bc1\u56db\uff1a\u6a21\u62dfclick\u4e8b\u4ef6<\/p>\n

1 <\/p>\n

2 <\/p>\n

3     <\/p>\n

4     <\/p>\n

5          #p { width: 300px; height: 300px; padding: 10px;  border: 1px solid black; }<\/p>\n

6          #c { width: 100px; height: 100px; border: 1px solid red; }<\/p>\n

7     <\/p>\n

8 <\/p>\n

9 <\/p>\n

10     <\/p>\n

\n

11         parent<\/p>\n

12         <\/p>\n

\n

13             child<\/p>\n

14         <\/p>\n<\/p><\/div>\n

15     <\/p>\n<\/p><\/div>\n

16     <\/p>\n

17         alert = function (msg) {
\n <\/p>\n

18             console.log(msg);<\/p>\n

19         }<\/p>\n

20<\/p>\n

21         var p = document.getElementById('p'),<\/p>\n

22         c = document.getElementById('c');<\/p>\n

23         c.addEventListener('click', function (e) {
\n <\/p>\n

24             console.log(e);<\/p>\n

25             alert('\u5b50\u8282\u70b9\u6355\u83b7')<\/p>\n

26         }, true);<\/p>\n

27         c.addEventListener('click', function (e) {
\n <\/p>\n

28             console.log(e);<\/p>\n

29             alert('\u5b50\u8282\u70b9\u5192\u6ce1')<\/p>\n

30         }, false);<\/p>\n

31<\/p>\n

32         p.addEventListener('click', function (e) {
\n <\/p>\n

33             console.log(e);<\/p>\n

34             alert('\u7236\u8282\u70b9\u6355\u83b7')<\/p>\n

35         }, true);<\/p>\n

36<\/p>\n

37         p.addEventListener('click', function (e) {
\n <\/p>\n

38             console.log(e);<\/p>\n

39             alert('\u7236\u8282\u70b9\u5192\u6ce1')<\/p>\n

40         }, false);<\/p>\n

41<\/p>\n

42         document.addEventListener('keydown', function (e) {
\n <\/p>\n

43             if (e.keyCode == '32') {
\n <\/p>\n

44                 var type = 'click'; \/\/\u8981\u89e6\u53d1\u7684\u4e8b\u4ef6\u7c7b\u578b<\/p>\n

45                 var bubbles = true; \/\/\u4e8b\u4ef6\u662f\u5426\u53ef\u4ee5\u5192\u6ce1<\/p>\n

46                 var cancelable = true; \/\/\u4e8b\u4ef6\u662f\u5426\u53ef\u4ee5\u963b\u6b62\u6d4f\u89c8\u5668\u9ed8\u8ba4\u4e8b\u4ef6<\/p>\n

47                 var view = document.defaultView; \/\/\u4e0e\u4e8b\u4ef6\u5173\u8054\u7684\u89c6\u56fe\uff0c\u8be5\u5c5e\u6027\u9ed8\u8ba4\u5373\u53ef\uff0c\u4e0d\u7ba1<\/p>\n

48                 var detail = 0;<\/p>\n

49                 var screenX = 0;<\/p>\n

50                 var screenY = 0;<\/p>\n

51                 var clientX = 0;<\/p>\n

52                 var clientY = 0;<\/p>\n

53                 var ctrlKey = false; \/\/\u662f\u5426\u6309\u4e0bctrl<\/p>\n

54                 var altKey = false; \/\/\u662f\u5426\u6309\u4e0balt<\/p>\n

55                 var shiftKey = false;<\/p>\n

56                 var metaKey = false;<\/p>\n

57                 var button = 0; \/\/\u8868\u793a\u6309\u4e0b\u54ea\u4e00\u4e2a\u9f20\u6807\u952e<\/p>\n

58                 var relatedTarget = 0; \/\/\u6a21\u62dfmousemove\u6216\u8005out\u65f6\u5019\u7528\u5230\uff0c\u4e0e\u4e8b\u4ef6\u76f8\u5173\u7684\u5bf9\u8c61<\/p>\n

59                 var event = document.createEvent('Events');<\/p>\n

60                 event.myFlag = '\u53f6\u5c0f\u9497';<\/p>\n

61                 event.initEvent(type, bubbles, cancelable, view, detail, screenX, screenY, clientX, clientY,<\/p>\n

62 ctrlKey, altKey, shiftKey, metaKey, button, relatedTarget);<\/p>\n

63<\/p>\n

64                 console.log(event);<\/p>\n

65                 c.dispatchEvent(event);<\/p>\n

66             }<\/p>\n

67         }, false);<\/p>\n

68     <\/p>\n

69 <\/p>\n

70 <\/p>\n

\u6211\u4eec\u6700\u540e\u6a21\u62df\u4e00\u4e0bclick\u4e8b\u4ef6\uff0c\u8fd9\u91cc\u6309\u7a7a\u683c\u4fbf\u4f1a\u89e6\u53d1child\u7684click\u4e8b\u4ef6\uff0c\u8fd9\u91cc\u4f9d\u7136\u8d70\u6211\u4eec\u4e0a\u8ff0\u903b\u8f91<\/p>\n

\u6240\u4ee5\uff0c\u6211\u4eec\u4eca\u5929\u5230\u6b64\u4e3a\u6b62\u3002<\/p>\n

\u7ed3\u8bed<\/p>\n

\u4eca\u5929\uff0c\u6211\u4eec\u4e00\u8d77\u6a21\u62df\u731c\u6d4b\u4e86javascript\u4e8b\u4ef6\u673a\u5236\u7684\u5e95\u5c42\u5b9e\u73b0\uff0c\u8fd9\u91cc\u53ea\u505a\u4e86\u6700\u7b80\u5355\u6700\u5355\u7eaf\u7684\u6a21\u62df<\/p>\n

\u6bd4\u5982\u4e24\u4e2a\u5e73\u7ea7dom(div)\u70b9\u51fb\u65f6\u5019\u8fd9\u91cc\u7684\u7b97\u6cd5\u5c31\u6709\u4e00\u70b9\u95ee\u9898\uff0c\u4f46\u662f\u65e0\u4f24\u5927\u96c5\uff0c\u63a2\u8ba8\u561b\uff0c\u81f3\u4e8e\u4e8b\u60c5\u7684\u771f\u76f8\u5982\u4f55\uff0c\u8fd9\u91cc\u5c31\u53ea\u80fd\u629b\u7816\u5f15\u7389\u4e86\u3002<\/p>\n

\u6b63\u786e\u7b54\u6848\u8981\u9700\u8981\u770bchrome\u6e90\u7801\u4e86\uff0c\u8fd9\u4e2a\u7559\u5f85\u6211\u4eec\u540e\u9762\u89e3\u7b54\u3002<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"html\u5e95\u5c42\u5b9e\u73b0\u539f\u7406,javascript\u4e8b\u4ef6\u673a\u5236\u5e95\u5c42\u5b9e\u73b0\u7684\u539f\u7406\u53c8\u5230\u4e86\u626f\u6de1\u65f6\u95f4\u4e86\uff0c\u6211\u6700\u8fd1\u5728\u601d\u8003javascript\u4e8b\u4ef6\u673a\u5236\u5e95\u5c42\u7684\u5b9e\u73b0\uff0c\u4f46\u662f\u6682\u65f6...","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"_links":{"self":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts\/9165"}],"collection":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/comments?post=9165"}],"version-history":[{"count":0,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts\/9165\/revisions"}],"wp:attachment":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/media?parent=9165"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/categories?post=9165"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/tags?post=9165"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}