{"id":79879,"date":"2026-03-03T15:10:46","date_gmt":"2026-03-03T07:10:46","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/79879.html"},"modified":"2026-03-03T15:10:46","modified_gmt":"2026-03-03T07:10:46","slug":"javascript%e4%b8%addocument%e5%af%b9%e8%b1%a1%e5%b8%b8%e8%a7%81%e7%9a%84%e7%9a%84%e6%96%b9%e6%b3%95%e5%88%86%e6%9e%90","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/79879.html","title":{"rendered":"JavaScript\u4e2dDocument\u5bf9\u8c61\u5e38\u89c1\u7684\u7684\u65b9\u6cd5\u5206\u6790"},"content":{"rendered":"<p>\u00a0 \u00a0 \u00a0 \u00a0 Document\u5bf9\u8c61\u7684\u65b9\u6cd5\u662fJavaScript\u64cd\u4f5cDOM\u7684\u6838\u5fc3\u624b\u6bb5&#xff0c;\u5b83\u80fd\u8ba9\u5f00\u53d1\u8005\u7cbe\u51c6\u83b7\u53d6\u3001\u521b\u5efa\u3001\u4fee\u6539\u9875\u9762\u5143\u7d20&#xff0c;\u8fd8\u80fd\u7ed1\u5b9a\u4e8b\u4ef6\u3001\u7ba1\u7406\u6837\u5f0f\u4e0e\u6587\u6863\u7ed3\u6784&#xff0c;\u662f\u5b9e\u73b0\u7f51\u9875\u52a8\u6001\u4ea4\u4e92\u3001\u5185\u5bb9\u66f4\u65b0\u4e0e\u5e03\u5c40\u8c03\u6574\u7684\u5173\u952e&#xff0c;\u652f\u6491\u7740\u524d\u7aef\u9875\u9762\u4ece\u9759\u6001\u5c55\u793a\u5230\u52a8\u6001\u4ea4\u4e92\u7684\u8f6c\u53d8&#xff0c;\u662f\u524d\u7aef\u5f00\u53d1\u4e2d\u5b9e\u73b0\u4e30\u5bcc\u7528\u6237\u4f53\u9a8c\u7684\u57fa\u7840\u5de5\u5177\u3002<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u5728\u73b0\u4ee3\u524d\u7aef\u5f00\u53d1\u4e2d&#xff0c;Document\u5bf9\u8c61\u7684\u65b9\u6cd5\u4f9d\u7136\u662f\u5404\u7c7b\u6846\u67b6\u5e95\u5c42\u4ea4\u4e92\u7684\u6838\u5fc3\u4f9d\u6258&#xff0c;\u5373\u4fbf\u6846\u67b6\u5c01\u88c5\u4e86\u66f4\u4e0a\u5c42\u7684API&#xff0c;\u5176\u672c\u8d28\u4ecd\u4f9d\u8d56Document\u65b9\u6cd5\u4e0e\u6d4f\u89c8\u5668DOM\u8fdb\u884c\u901a\u4fe1\u3002\u672a\u6765\u968f\u7740Web\u6807\u51c6\u7684\u6301\u7eed\u6f14\u8fdb&#xff0c;\u5b83\u7684\u65b9\u6cd5\u4f1a\u66f4\u4fa7\u91cd\u5b89\u5168\u4e0e\u8bed\u4e49\u5316&#xff0c;\u6bd4\u5982\u5728\u8de8\u57df\u4ea4\u4e92\u3001\u9690\u79c1\u4fdd\u62a4\u5c42\u9762\u7684\u9650\u5236\u4f1a\u66f4\u4e25\u683c&#xff0c;\u540c\u65f6\u4e5f\u4f1a\u8fdb\u4e00\u6b65\u5f3a\u5316\u4e0eWeb\u7ec4\u4ef6\u3001\u6e10\u8fdb\u5f0fWeb\u5e94\u7528&#xff08;PWA&#xff09;\u7684\u534f\u540c\u80fd\u529b&#xff0c;\u66f4\u597d\u5730\u9002\u914d\u591a\u7aef\u3001\u79bb\u7ebf\u7b49\u590d\u6742\u573a\u666f&#xff0c;\u6210\u4e3a\u6784\u5efa\u4e0b\u4e00\u4ee3Web\u5e94\u7528\u7684\u91cd\u8981\u57fa\u7840\u3002<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0\u00a0\u00a0 \u4e0b\u9762&#xff0c;\u5bf9JavaScript\u4e2dDocument\u5bf9\u8c61\u5e38\u89c1\u7684\u65b9\u6cd5\u8fdb\u884c\u9010\u4e00\u5206\u6790\u8bb2\u89e3&#xff1a;<\/p>\n<hr \/>\n<h2>\u7b2c\u4e00\u90e8\u5206&#xff1a;\u4e8b\u4ef6\u5904\u7406\u65b9\u6cd5&#xff08;4\u4e2a&#xff09;<\/h2>\n<h3>1\u3001document.addEventListener()<\/h3>\n<ul>\n<li>\n<p>\u542b\u4e49&#xff1a;\u4e3a\u6587\u6863\u6dfb\u52a0\u4e8b\u4ef6\u76d1\u542c\u5668&#xff0c;\u5f53\u6307\u5b9a\u4e8b\u4ef6\u53d1\u751f\u65f6\u6267\u884c\u56de\u8c03\u51fd\u6570\u3002<\/p>\n<\/li>\n<li>\n<p>\u8bcd\u6e90&#xff1a;Add&#xff08;\u6dfb\u52a0&#xff09;&#043; Event&#xff08;\u4e8b\u4ef6&#xff09;&#043; Listener&#xff08;\u76d1\u542c\u5668&#xff09;\u3002<\/p>\n<\/li>\n<li>\n<p>\u8bed\u6cd5&#xff1a;document.addEventListener(type, listener, options);<\/p>\n<\/li>\n<li>\n<p>\u53c2\u6570\u53ca\u8bf4\u660e&#xff1a;<\/p>\n<ul>\n<li>\n<p>type&#xff1a;\u4e8b\u4ef6\u7c7b\u578b\u5b57\u7b26\u4e32&#xff0c;\u5982\u00a0&#039;click&#039;\u3001&#039;keydown&#039;\u3001&#039;scroll&#039;\u3002<\/p>\n<\/li>\n<li>\n<p>listener&#xff1a;\u4e8b\u4ef6\u89e6\u53d1\u65f6\u8981\u6267\u884c\u7684\u56de\u8c03\u51fd\u6570&#xff0c;\u63a5\u6536\u4e00\u4e2a\u4e8b\u4ef6\u5bf9\u8c61\u53c2\u6570\u3002<\/p>\n<\/li>\n<li>\n<p>options&#xff08;\u53ef\u9009&#xff09;&#xff1a;\u53ef\u4ee5\u662f\u5e03\u5c14\u503c\u6216\u5bf9\u8c61\u3002<\/p>\n<ul>\n<li>\n<p>\u5982\u679c\u662f\u5e03\u5c14\u503c&#xff1a;true\u00a0\u8868\u793a\u5728\u6355\u83b7\u9636\u6bb5\u89e6\u53d1&#xff0c;false\u00a0\u8868\u793a\u5728\u5192\u6ce1\u9636\u6bb5\u89e6\u53d1\u3002<\/p>\n<\/li>\n<li>\n<p>\u5982\u679c\u662f\u5bf9\u8c61&#xff0c;\u53ef\u4ee5\u5305\u542b&#xff1a;<\/p>\n<ul>\n<li>\n<p>capture&#xff1a;\u5e03\u5c14\u503c&#xff0c;\u662f\u5426\u5728\u6355\u83b7\u9636\u6bb5\u89e6\u53d1\u3002<\/p>\n<\/li>\n<li>\n<p>once&#xff1a;\u5e03\u5c14\u503c&#xff0c;\u662f\u5426\u53ea\u89e6\u53d1\u4e00\u6b21\u540e\u81ea\u52a8\u79fb\u9664\u3002<\/p>\n<\/li>\n<li>\n<p>passive&#xff1a;\u5e03\u5c14\u503c&#xff0c;\u662f\u5426\u6c38\u4e0d\u8c03\u7528\u00a0preventDefault()\u3002<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u4f8b\u5b50&#xff1a;<\/p>\n<p>\/\/ \u57fa\u672c\u7528\u6cd5<br \/>\ndocument.addEventListener(&#039;click&#039;, function(event) {<br \/>\n    console.log(&#039;\u6587\u6863\u88ab\u70b9\u51fb\u4e86&#039;, event.clientX, event.clientY);<br \/>\n});<\/p>\n<p>\/\/ \u53ea\u89e6\u53d1\u4e00\u6b21\u7684\u76d1\u542c\u5668<br \/>\ndocument.addEventListener(&#039;DOMContentLoaded&#039;, function() {<br \/>\n    console.log(&#039;\u9875\u9762\u52a0\u8f7d\u5b8c\u6210&#xff0c;\u53ea\u89e6\u53d1\u4e00\u6b21&#039;);<br \/>\n}, { once: true });<\/p>\n<p>\/\/ \u4f7f\u7528\u7bad\u5934\u51fd\u6570\u548c\u6355\u83b7\u9636\u6bb5<br \/>\ndocument.addEventListener(&#039;scroll&#039;, () &#061;&gt; {<br \/>\n    console.log(&#039;\u9875\u9762\u6eda\u52a8\u4e2d&#039;, window.scrollY);<br \/>\n}, { capture: true });\n<\/li>\n<\/ul>\n<h3>2\u3001document.removeEventListener()<\/h3>\n<ul>\n<li>\n<p>\u542b\u4e49&#xff1a;\u79fb\u9664\u4e4b\u524d\u901a\u8fc7\u00a0addEventListener\u00a0\u6dfb\u52a0\u7684\u4e8b\u4ef6\u76d1\u542c\u5668\u3002<\/p>\n<\/li>\n<li>\n<p>\u8bcd\u6e90&#xff1a;Remove&#xff08;\u79fb\u9664&#xff09;&#043; Event&#xff08;\u4e8b\u4ef6&#xff09;&#043; Listener&#xff08;\u76d1\u542c\u5668&#xff09;\u3002<\/p>\n<\/li>\n<li>\n<p>\u8bed\u6cd5&#xff1a;document.removeEventListener(type, listener, options);<\/p>\n<\/li>\n<li>\n<p>\u53c2\u6570\u53ca\u8bf4\u660e&#xff1a;<\/p>\n<ul>\n<li>\n<p>type&#xff1a;\u8981\u79fb\u9664\u7684\u4e8b\u4ef6\u7c7b\u578b\u3002<\/p>\n<\/li>\n<li>\n<p>listener&#xff1a;\u8981\u79fb\u9664\u7684\u56de\u8c03\u51fd\u6570&#xff08;\u5fc5\u987b\u662f\u540c\u4e00\u4e2a\u51fd\u6570\u5f15\u7528&#xff09;\u3002<\/p>\n<\/li>\n<li>\n<p>options&#xff08;\u53ef\u9009&#xff09;&#xff1a;\u5fc5\u987b\u4e0e\u6dfb\u52a0\u65f6\u7684\u914d\u7f6e\u4e00\u81f4\u624d\u80fd\u6b63\u786e\u79fb\u9664\u3002<\/p>\n<\/li>\n<li>\n<p>\u91cd\u8981&#xff1a;\u5982\u679c\u6dfb\u52a0\u65f6\u4f7f\u7528\u7684\u662f\u533f\u540d\u51fd\u6570&#xff0c;\u5219\u65e0\u6cd5\u79fb\u9664\u3002<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u4f8b\u5b50&#xff1a;<\/p>\n<p>\/\/ \u5b9a\u4e49\u547d\u540d\u51fd\u6570\u624d\u80fd\u79fb\u9664<br \/>\nfunction handleClick(event) {<br \/>\n    console.log(&#039;\u70b9\u51fb\u4e86\u6587\u6863&#039;);<br \/>\n}<\/p>\n<p>\/\/ \u6dfb\u52a0\u76d1\u542c\u5668<br \/>\ndocument.addEventListener(&#039;click&#039;, handleClick);<\/p>\n<p>\/\/ \u540e\u7eed\u79fb\u9664\u76d1\u542c\u5668<br \/>\ndocument.removeEventListener(&#039;click&#039;, handleClick);<\/p>\n<p>\/\/ \u9519\u8bef\u793a\u8303&#xff1a;\u65e0\u6cd5\u79fb\u9664\u533f\u540d\u51fd\u6570<br \/>\ndocument.addEventListener(&#039;click&#039;, function() {<br \/>\n    console.log(&#039;\u8fd9\u4e2a\u76d1\u542c\u5668\u65e0\u6cd5\u88ab\u79fb\u9664&#039;);<br \/>\n});<br \/>\n\/\/ document.removeEventListener(&#039;click&#039;, &#8230;) \/\/ \u65e0\u6cd5\u79fb\u9664\u4e0a\u9762\u7684\u533f\u540d\u51fd\u6570\n<\/li>\n<\/ul>\n<h3>3\u3001document.dispatchEvent()<\/h3>\n<ul>\n<li>\n<p>\u542b\u4e49&#xff1a;\u5411\u6587\u6863\u6d3e\u53d1\u4e00\u4e2a\u81ea\u5b9a\u4e49\u4e8b\u4ef6&#xff0c;\u89e6\u53d1\u76f8\u5e94\u7684\u4e8b\u4ef6\u76d1\u542c\u5668\u3002<\/p>\n<\/li>\n<li>\n<p>\u8bcd\u6e90&#xff1a;Dispatch&#xff08;\u6d3e\u9063\u3001\u53d1\u9001&#xff09;&#043; Event&#xff08;\u4e8b\u4ef6&#xff09;\u3002<\/p>\n<\/li>\n<li>\n<p>\u8bed\u6cd5&#xff1a;let result &#061; document.dispatchEvent(event);<\/p>\n<\/li>\n<li>\n<p>\u53c2\u6570\u53ca\u8bf4\u660e&#xff1a;<\/p>\n<ul>\n<li>\n<p>event&#xff1a;\u8981\u6d3e\u53d1\u7684\u4e8b\u4ef6\u5bf9\u8c61&#xff08;\u53ef\u4ee5\u662f\u00a0new Event()\u00a0\u521b\u5efa\u7684\u81ea\u5b9a\u4e49\u4e8b\u4ef6&#xff0c;\u4e5f\u53ef\u4ee5\u662f\u7cfb\u7edf\u4e8b\u4ef6&#xff09;\u3002<\/p>\n<\/li>\n<li>\n<p>\u8fd4\u56de\u503c&#xff1a;\u5e03\u5c14\u503c\u3002\u5982\u679c\u4e8b\u4ef6\u6ca1\u6709\u88ab\u4efb\u4f55\u76d1\u542c\u5668\u8c03\u7528\u00a0preventDefault()\u00a0\u5219\u8fd4\u56de\u00a0true&#xff0c;\u5426\u5219\u8fd4\u56de\u00a0false\u3002<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u4f8b\u5b50&#xff1a;<\/p>\n<p>\/\/ \u521b\u5efa\u5e76\u6d3e\u53d1\u81ea\u5b9a\u4e49\u4e8b\u4ef6<br \/>\nlet customEvent &#061; new Event(&#039;userLogin&#039;);<\/p>\n<p>\/\/ \u76d1\u542c\u81ea\u5b9a\u4e49\u4e8b\u4ef6<br \/>\ndocument.addEventListener(&#039;userLogin&#039;, function(e) {<br \/>\n    console.log(&#039;\u7528\u6237\u767b\u5f55\u4e8b\u4ef6\u89e6\u53d1&#039;, e.type);<br \/>\n    document.body.style.backgroundColor &#061; &#039;lightgreen&#039;;<br \/>\n});<\/p>\n<p>\/\/ \u6d3e\u53d1\u4e8b\u4ef6<br \/>\nlet result &#061; document.dispatchEvent(customEvent);<br \/>\nconsole.log(&#039;\u4e8b\u4ef6\u6d3e\u53d1\u6210\u529f&#xff1f;&#039;, result); \/\/ true<\/p>\n<p>\/\/ \u5e26\u6570\u636e\u7684\u81ea\u5b9a\u4e49\u4e8b\u4ef6<br \/>\nlet dataEvent &#061; new CustomEvent(&#039;dataUpdate&#039;, {<br \/>\n    detail: { name: &#039;\u5f20\u4e09&#039;, age: 25 }<br \/>\n});<\/p>\n<p>document.addEventListener(&#039;dataUpdate&#039;, function(e) {<br \/>\n    console.log(&#039;\u63a5\u6536\u5230\u7684\u6570\u636e&#xff1a;&#039;, e.detail); \/\/ { name: &#039;\u5f20\u4e09&#039;, age: 25 }<br \/>\n});<\/p>\n<p>document.dispatchEvent(dataEvent);\n<\/li>\n<\/ul>\n<h3>4\u3001document.execCommand()<\/h3>\n<ul>\n<li>\n<p>\u542b\u4e49&#xff1a;\u6267\u884c\u547d\u4ee4\u64cd\u4f5c\u53ef\u7f16\u8f91\u533a\u57df\u7684\u5185\u5bb9&#xff08;\u5df2\u5e9f\u5f03&#xff0c;\u4f46\u4ecd\u5728\u90e8\u5206\u6d4f\u89c8\u5668\u4e2d\u652f\u6301&#xff09;\u3002<\/p>\n<\/li>\n<li>\n<p>\u8bcd\u6e90&#xff1a;Exec&#xff08;\u6267\u884c&#xff09;&#043; Command&#xff08;\u547d\u4ee4&#xff09;\u3002<\/p>\n<\/li>\n<li>\n<p>\u8bed\u6cd5&#xff1a;let result &#061; document.execCommand(command, showUI, value);<\/p>\n<\/li>\n<li>\n<p>\u53c2\u6570\u53ca\u8bf4\u660e&#xff1a;<\/p>\n<ul>\n<li>\n<p>command&#xff1a;\u547d\u4ee4\u540d\u79f0\u5b57\u7b26\u4e32\u3002\u5e38\u7528\u547d\u4ee4&#xff1a;<\/p>\n<ul>\n<li>\n<p>&#039;bold&#039;&#xff1a;\u52a0\u7c97\u9009\u4e2d\u6587\u672c<\/p>\n<\/li>\n<li>\n<p>&#039;italic&#039;&#xff1a;\u659c\u4f53<\/p>\n<\/li>\n<li>\n<p>&#039;underline&#039;&#xff1a;\u4e0b\u5212\u7ebf<\/p>\n<\/li>\n<li>\n<p>&#039;copy&#039;&#xff1a;\u590d\u5236\u9009\u4e2d\u5185\u5bb9<\/p>\n<\/li>\n<li>\n<p>&#039;cut&#039;&#xff1a;\u526a\u5207\u9009\u4e2d\u5185\u5bb9<\/p>\n<\/li>\n<li>\n<p>&#039;paste&#039;&#xff1a;\u7c98\u8d34<\/p>\n<\/li>\n<li>\n<p>&#039;createLink&#039;&#xff1a;\u521b\u5efa\u94fe\u63a5<\/p>\n<\/li>\n<li>\n<p>&#039;insertImage&#039;&#xff1a;\u63d2\u5165\u56fe\u7247<\/p>\n<\/li>\n<li>\n<p>&#039;undo&#039;&#xff1a;\u64a4\u9500<\/p>\n<\/li>\n<li>\n<p>&#039;redo&#039;&#xff1a;\u91cd\u505a<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>showUI&#xff1a;\u5e03\u5c14\u503c&#xff0c;\u662f\u5426\u663e\u793a\u547d\u4ee4\u7684\u7528\u6237\u754c\u9762&#xff08;\u901a\u5e38\u8bbe\u4e3a\u00a0false&#xff09;\u3002<\/p>\n<\/li>\n<li>\n<p>value&#xff1a;\u547d\u4ee4\u9700\u8981\u7684\u53c2\u6570\u503c&#xff08;\u5982\u94fe\u63a5 URL\u3001\u56fe\u7247\u5730\u5740\u7b49&#xff09;\u3002<\/p>\n<\/li>\n<li>\n<p>\u8fd4\u56de\u503c&#xff1a;\u5e03\u5c14\u503c&#xff0c;\u8868\u793a\u547d\u4ee4\u662f\u5426\u6267\u884c\u6210\u529f\u3002<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u4f8b\u5b50&#xff1a;<\/p>\n<p>\/\/ \u9700\u8981\u6709\u4e00\u4e2a\u53ef\u7f16\u8f91\u533a\u57df<br \/>\n\/\/ &lt;div contenteditable&#061;&#034;true&#034; id&#061;&#034;editor&#034;&gt;\u8fd9\u662f\u53ef\u7f16\u8f91\u6587\u672c&lt;\/div&gt;<\/p>\n<p>let editor &#061; document.getElementById(&#039;editor&#039;);<br \/>\neditor.focus(); \/\/ \u5148\u8ba9\u7f16\u8f91\u5668\u83b7\u5f97\u7126\u70b9<\/p>\n<p>\/\/ \u5c06\u9009\u4e2d\u6587\u672c\u52a0\u7c97<br \/>\nlet success &#061; document.execCommand(&#039;bold&#039;, false, null);<br \/>\nconsole.log(&#039;\u52a0\u7c97\u6210\u529f&#xff1f;&#039;, success);<\/p>\n<p>\/\/ \u521b\u5efa\u94fe\u63a5<br \/>\ndocument.execCommand(&#039;createLink&#039;, false, &#039;https:\/\/example.com&#039;);<\/p>\n<p>\/\/ \u590d\u5236\u9009\u4e2d\u7684\u5185\u5bb9<br \/>\ndocument.execCommand(&#039;copy&#039;);<\/p>\n<p>\/\/ \u6ce8\u610f&#xff1a;\u73b0\u4ee3\u5f00\u53d1\u63a8\u8350\u4f7f\u7528 Clipboard API \u66ff\u4ee3<br \/>\n\/\/ navigator.clipboard.writeText(&#039;\u8981\u590d\u5236\u7684\u6587\u672c&#039;);\n<\/li>\n<\/ul>\n<hr \/>\n<h2>\u7b2c\u4e8c\u90e8\u5206&#xff1a;\u8282\u70b9\u5bfc\u5165\u4e0e\u91c7\u7528\u65b9\u6cd5&#xff08;2\u4e2a&#xff09;<\/h2>\n<h3>5\u3001document.adoptNode()<\/h3>\n<ul>\n<li>\n<p>\u542b\u4e49&#xff1a;\u4ece\u5176\u4ed6\u6587\u6863\u4e2d\u91c7\u7528\u4e00\u4e2a\u8282\u70b9&#xff0c;\u4f7f\u5176\u5f52\u5c5e\u4e8e\u5f53\u524d\u6587\u6863&#xff08;\u539f\u6587\u6863\u4e2d\u7684\u8282\u70b9\u4f1a\u88ab\u79fb\u9664&#xff09;\u3002<\/p>\n<\/li>\n<li>\n<p>\u8bcd\u6e90&#xff1a;Adopt&#xff08;\u91c7\u7528\u3001\u6536\u517b&#xff09;&#043; Node&#xff08;\u8282\u70b9&#xff09;\u3002<\/p>\n<\/li>\n<li>\n<p>\u8bed\u6cd5&#xff1a;let node &#061; document.adoptNode(externalNode);<\/p>\n<\/li>\n<li>\n<p>\u53c2\u6570\u53ca\u8bf4\u660e&#xff1a;<\/p>\n<ul>\n<li>\n<p>externalNode&#xff1a;\u6765\u81ea\u5176\u4ed6\u6587\u6863\u7684\u8282\u70b9&#xff08;\u5982 iframe \u4e2d\u7684\u5143\u7d20&#xff09;\u3002<\/p>\n<\/li>\n<li>\n<p>\u8fd4\u56de\u503c&#xff1a;\u88ab\u91c7\u7528\u540e\u7684\u8282\u70b9&#xff0c;\u5176\u00a0ownerDocument\u00a0\u53d8\u4e3a\u5f53\u524d\u6587\u6863\u3002<\/p>\n<\/li>\n<li>\n<p>\u6ce8\u610f&#xff1a;\u91c7\u7528\u540e&#xff0c;\u539f\u6587\u6863\u4e2d\u7684\u8282\u70b9\u4f1a\u88ab\u79fb\u9664\u3002<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u4f8b\u5b50&#xff1a;<\/p>\n<p>\/\/ \u5047\u8bbe\u9875\u9762\u4e2d\u6709\u4e00\u4e2a iframe<br \/>\n\/\/ &lt;iframe id&#061;&#034;myIframe&#034; src&#061;&#034;other.html&#034;&gt;&lt;\/iframe&gt;<\/p>\n<p>let iframe &#061; document.getElementById(&#039;myIframe&#039;);<br \/>\nlet iframeDoc &#061; iframe.contentDocument;<\/p>\n<p>\/\/ \u83b7\u53d6 iframe \u4e2d\u7684\u4e00\u4e2a\u6309\u94ae<br \/>\nlet iframeButton &#061; iframeDoc.getElementById(&#039;btnFromIframe&#039;);<\/p>\n<p>\/\/ \u5c06\u6309\u94ae\u4ece iframe \u6587\u6863\u91c7\u7528\u5230\u4e3b\u6587\u6863<br \/>\nlet adoptedBtn &#061; document.adoptNode(iframeButton);<\/p>\n<p>\/\/ \u73b0\u5728\u6309\u94ae\u5df2\u4ece iframe \u4e2d\u79fb\u9664&#xff0c;\u9700\u8981\u624b\u52a8\u6dfb\u52a0\u5230\u4e3b\u6587\u6863<br \/>\ndocument.body.appendChild(adoptedBtn);<\/p>\n<p>console.log(&#039;\u6309\u94ae\u5df2\u79fb\u52a8\u5230\u4e3b\u6587\u6863&#039;);\n<\/li>\n<\/ul>\n<h3>6\u3001document.importNode()<\/h3>\n<ul>\n<li>\n<p>\u542b\u4e49&#xff1a;\u4ece\u5176\u4ed6\u6587\u6863\u5bfc\u5165\u4e00\u4e2a\u8282\u70b9\u5230\u5f53\u524d\u6587\u6863&#xff08;\u521b\u5efa\u526f\u672c&#xff0c;\u539f\u8282\u70b9\u4fdd\u7559&#xff09;\u3002<\/p>\n<\/li>\n<li>\n<p>\u8bcd\u6e90&#xff1a;Import&#xff08;\u5bfc\u5165&#xff09;&#043; Node&#xff08;\u8282\u70b9&#xff09;\u3002<\/p>\n<\/li>\n<li>\n<p>\u8bed\u6cd5&#xff1a;let node &#061; document.importNode(externalNode, deep);<\/p>\n<\/li>\n<li>\n<p>\u53c2\u6570\u53ca\u8bf4\u660e&#xff1a;<\/p>\n<ul>\n<li>\n<p>externalNode&#xff1a;\u6765\u81ea\u5176\u4ed6\u6587\u6863\u7684\u8282\u70b9\u3002<\/p>\n<\/li>\n<li>\n<p>deep&#xff1a;\u5e03\u5c14\u503c\u3002true\u00a0\u8868\u793a\u6df1\u5ea6\u5bfc\u5165&#xff08;\u5305\u62ec\u6240\u6709\u5b50\u8282\u70b9&#xff09;&#xff0c;false\u00a0\u53ea\u5bfc\u5165\u8282\u70b9\u672c\u8eab\u3002<\/p>\n<\/li>\n<li>\n<p>\u8fd4\u56de\u503c&#xff1a;\u5bfc\u5165\u540e\u7684\u8282\u70b9\u526f\u672c&#xff0c;\u539f\u8282\u70b9\u4e0d\u53d7\u5f71\u54cd\u3002<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u4f8b\u5b50&#xff1a;<\/p>\n<p>\/\/ \u5047\u8bbe\u6709 iframe<br \/>\nlet iframe &#061; document.getElementById(&#039;myIframe&#039;);<br \/>\nlet iframeDoc &#061; iframe.contentDocument;<\/p>\n<p>\/\/ \u83b7\u53d6 iframe \u4e2d\u7684\u4e00\u4e2a\u590d\u6742\u5143\u7d20<br \/>\nlet iframeDiv &#061; iframeDoc.getElementById(&#039;complexDiv&#039;);<\/p>\n<p>\/\/ \u6df1\u5ea6\u5bfc\u5165\u8be5\u5143\u7d20\u53ca\u5176\u6240\u6709\u5b50\u8282\u70b9<br \/>\nlet importedDiv &#061; document.importNode(iframeDiv, true);<\/p>\n<p>\/\/ \u5c06\u5bfc\u5165\u7684\u526f\u672c\u6dfb\u52a0\u5230\u4e3b\u6587\u6863<br \/>\ndocument.body.appendChild(importedDiv);<\/p>\n<p>\/\/ iframe \u4e2d\u7684\u539f\u5143\u7d20\u4ecd\u7136\u5b58\u5728<br \/>\nconsole.log(&#039;\u539f\u8282\u70b9\u4ecd\u5728 iframe \u4e2d&#xff0c;\u526f\u672c\u5df2\u6dfb\u52a0\u5230\u4e3b\u6587\u6863&#039;);\n<\/li>\n<\/ul>\n<hr \/>\n<h2>\u7b2c\u4e09\u90e8\u5206&#xff1a;\u8282\u70b9\u64cd\u4f5c\u65b9\u6cd5&#xff08;10\u4e2a&#xff09;<\/h2>\n<h3>7\u3001document.appendChild()<\/h3>\n<ul>\n<li>\n<p>\u542b\u4e49&#xff1a;\u5411\u6587\u6863\u8282\u70b9\u7684\u5b50\u8282\u70b9\u5217\u8868\u672b\u5c3e\u6dfb\u52a0\u4e00\u4e2a\u8282\u70b9\u3002<\/p>\n<\/li>\n<li>\n<p>\u8bcd\u6e90&#xff1a;Append&#xff08;\u8ffd\u52a0&#xff09;&#043; Child&#xff08;\u5b69\u5b50&#xff09;\u3002<\/p>\n<\/li>\n<li>\n<p>\u8bed\u6cd5&#xff1a;document.appendChild(aChild);<\/p>\n<\/li>\n<li>\n<p>\u53c2\u6570\u53ca\u8bf4\u660e&#xff1a;<\/p>\n<ul>\n<li>\n<p>aChild&#xff1a;\u8981\u8ffd\u52a0\u7684\u8282\u70b9\u5bf9\u8c61\u3002<\/p>\n<\/li>\n<li>\n<p>\u91cd\u8981\u8b66\u544a&#xff1a;\u901a\u5e38\u4e0d\u76f4\u63a5\u5bf9\u00a0document\u00a0\u4f7f\u7528\u00a0appendChild&#xff0c;\u56e0\u4e3a\u6587\u6863\u53ea\u80fd\u6709\u4e00\u4e2a\u6839\u5143\u7d20\u00a0&lt;html&gt;\u3002\u5982\u679c\u5c1d\u8bd5\u6dfb\u52a0\u53e6\u4e00\u4e2a\u6839\u5143\u7d20\u4f1a\u51fa\u9519\u3002<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u4f8b\u5b50&#xff1a;<\/p>\n<p>\/\/ \u9519\u8bef\u793a\u8303&#xff1a;\u4e0d\u80fd\u7ed9 document \u76f4\u63a5\u6dfb\u52a0\u5b50\u8282\u70b9<br \/>\n\/\/ let newDiv &#061; document.createElement(&#039;div&#039;);<br \/>\n\/\/ document.appendChild(newDiv); \/\/ \u4f1a\u62a5\u9519<\/p>\n<p>\/\/ \u6b63\u786e\u7528\u6cd5&#xff1a;\u901a\u5e38\u5bf9 document.body \u6216\u5176\u4ed6\u5143\u7d20\u4f7f\u7528<br \/>\nlet newDiv &#061; document.createElement(&#039;div&#039;);<br \/>\ndocument.body.appendChild(newDiv); \/\/ \u2705 \u6b63\u786e\n<\/li>\n<\/ul>\n<h3>8\u3001document.cloneNode()<\/h3>\n<ul>\n<li>\n<p>\u542b\u4e49&#xff1a;\u514b\u9686\u6587\u6863\u8282\u70b9\u672c\u8eab&#xff08;\u4e0d\u662f\u514b\u9686\u6574\u4e2a\u9875\u9762\u5185\u5bb9&#xff09;\u3002<\/p>\n<\/li>\n<li>\n<p>\u8bcd\u6e90&#xff1a;Clone&#xff08;\u514b\u9686&#xff09;&#043; Node&#xff08;\u8282\u70b9&#xff09;\u3002<\/p>\n<\/li>\n<li>\n<p>\u8bed\u6cd5&#xff1a;let clonedDoc &#061; document.cloneNode(deep);<\/p>\n<\/li>\n<li>\n<p>\u53c2\u6570\u53ca\u8bf4\u660e&#xff1a;<\/p>\n<ul>\n<li>\n<p>deep&#xff1a;\u5e03\u5c14\u503c\u3002true\u00a0\u8868\u793a\u6df1\u5ea6\u514b\u9686&#xff08;\u5305\u62ec\u6240\u6709\u5b50\u8282\u70b9&#xff09;&#xff0c;false\u00a0\u53ea\u514b\u9686\u6587\u6863\u8282\u70b9\u672c\u8eab\u3002<\/p>\n<\/li>\n<li>\n<p>\u8fd4\u56de\u503c&#xff1a;\u514b\u9686\u540e\u7684\u6587\u6863\u8282\u70b9\u526f\u672c\u3002<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u4f8b\u5b50&#xff1a;<\/p>\n<p>\/\/ \u6d45\u514b\u9686 &#8211; \u53ea\u514b\u9686 document \u5bf9\u8c61\u672c\u8eab&#xff0c;\u4e0d\u5305\u542b\u5b50\u8282\u70b9<br \/>\nlet docShallow &#061; document.cloneNode(false);<br \/>\nconsole.log(docShallow.nodeName); \/\/ &#039;#document&#039;<br \/>\nconsole.log(docShallow.hasChildNodes()); \/\/ false&#xff08;\u6ca1\u6709\u5b50\u8282\u70b9&#xff09;<\/p>\n<p>\/\/ \u6df1\u514b\u9686 &#8211; \u514b\u9686\u6574\u4e2a\u6587\u6863\u7ed3\u6784<br \/>\nlet docDeep &#061; document.cloneNode(true);<br \/>\nconsole.log(docDeep.childNodes.length); \/\/ \u5305\u542b doctype \u548c html \u7b49<br \/>\n\/\/ \u6ce8\u610f&#xff1a;\u514b\u9686\u7684\u6587\u6863\u4e0d\u5728\u9875\u9762\u4e2d\u663e\u793a&#xff0c;\u53ea\u662f\u4e00\u4e2a\u5185\u5b58\u4e2d\u7684\u526f\u672c\n<\/li>\n<\/ul>\n<h3>9\u3001document.insertBefore()<\/h3>\n<ul>\n<li>\n<p>\u542b\u4e49&#xff1a;\u5728\u53c2\u8003\u8282\u70b9\u4e4b\u524d\u63d2\u5165\u4e00\u4e2a\u8282\u70b9\u3002<\/p>\n<\/li>\n<li>\n<p>\u8bcd\u6e90&#xff1a;Insert&#xff08;\u63d2\u5165&#xff09;&#043; Before&#xff08;\u5728&#8230;\u4e4b\u524d&#xff09;\u3002<\/p>\n<\/li>\n<li>\n<p>\u8bed\u6cd5&#xff1a;let insertedNode &#061; parentNode.insertBefore(newNode, referenceNode);<\/p>\n<\/li>\n<li>\n<p>\u53c2\u6570\u53ca\u8bf4\u660e&#xff1a;<\/p>\n<ul>\n<li>\n<p>newNode&#xff1a;\u8981\u63d2\u5165\u7684\u65b0\u8282\u70b9\u3002<\/p>\n<\/li>\n<li>\n<p>referenceNode&#xff1a;\u53c2\u8003\u8282\u70b9&#xff08;\u65b0\u8282\u70b9\u5c06\u63d2\u5165\u5230\u8fd9\u4e2a\u8282\u70b9\u4e4b\u524d&#xff09;\u3002<\/p>\n<\/li>\n<li>\n<p>\u8fd4\u56de\u503c&#xff1a;\u88ab\u63d2\u5165\u7684\u8282\u70b9\u3002<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u4f8b\u5b50&#xff1a;<\/p>\n<p>\/\/ \u901a\u5e38\u5bf9\u5177\u4f53\u5143\u7d20\u4f7f\u7528&#xff0c;\u800c\u4e0d\u662f document<br \/>\nlet parent &#061; document.getElementById(&#039;parentDiv&#039;);<br \/>\nlet firstChild &#061; parent.firstElementChild;<\/p>\n<p>let newSpan &#061; document.createElement(&#039;span&#039;);<br \/>\nnewSpan.textContent &#061; &#039;\u63d2\u5165\u7684span&#039;;<\/p>\n<p>\/\/ \u5728\u7b2c\u4e00\u4e2a\u5b50\u5143\u7d20\u4e4b\u524d\u63d2\u5165\u65b0span<br \/>\nparent.insertBefore(newSpan, firstChild);\n<\/li>\n<\/ul>\n<h3>10\u3001document.replaceChild()<\/h3>\n<ul>\n<li>\n<p>\u542b\u4e49&#xff1a;\u7528\u65b0\u8282\u70b9\u66ff\u6362\u7236\u8282\u70b9\u4e2d\u7684\u4e00\u4e2a\u5b50\u8282\u70b9\u3002<\/p>\n<\/li>\n<li>\n<p>\u8bcd\u6e90&#xff1a;Replace&#xff08;\u66ff\u6362&#xff09;&#043; Child&#xff08;\u5b69\u5b50&#xff09;\u3002<\/p>\n<\/li>\n<li>\n<p>\u8bed\u6cd5&#xff1a;let oldChild &#061; parentNode.replaceChild(newChild, oldChild);<\/p>\n<\/li>\n<li>\n<p>\u53c2\u6570\u53ca\u8bf4\u660e&#xff1a;<\/p>\n<ul>\n<li>\n<p>newChild&#xff1a;\u65b0\u8282\u70b9\u3002<\/p>\n<\/li>\n<li>\n<p>oldChild&#xff1a;\u8981\u88ab\u66ff\u6362\u7684\u65e7\u5b50\u8282\u70b9\u3002<\/p>\n<\/li>\n<li>\n<p>\u8fd4\u56de\u503c&#xff1a;\u88ab\u66ff\u6362\u7684\u65e7\u8282\u70b9\u3002<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u4f8b\u5b50&#xff1a;<\/p>\n<p>let parent &#061; document.getElementById(&#039;container&#039;);<br \/>\nlet oldP &#061; document.getElementById(&#039;oldParagraph&#039;);<\/p>\n<p>let newDiv &#061; document.createElement(&#039;div&#039;);<br \/>\nnewDiv.textContent &#061; &#039;\u66ff\u6362\u540e\u7684\u65b0\u5185\u5bb9&#039;;<br \/>\nnewDiv.className &#061; &#039;new-content&#039;;<\/p>\n<p>\/\/ \u7528 newDiv \u66ff\u6362 oldP<br \/>\nlet removed &#061; parent.replaceChild(newDiv, oldP);<br \/>\nconsole.log(&#039;\u5df2\u79fb\u9664\u7684\u8282\u70b9&#xff1a;&#039;, removed);\n<\/li>\n<\/ul>\n<h3>11\u3001document.removeChild()<\/h3>\n<ul>\n<li>\n<p>\u542b\u4e49&#xff1a;\u4ece\u7236\u8282\u70b9\u4e2d\u79fb\u9664\u4e00\u4e2a\u5b50\u8282\u70b9\u3002<\/p>\n<\/li>\n<li>\n<p>\u8bcd\u6e90&#xff1a;Remove&#xff08;\u79fb\u9664&#xff09;&#043; Child&#xff08;\u5b69\u5b50&#xff09;\u3002<\/p>\n<\/li>\n<li>\n<p>\u8bed\u6cd5&#xff1a;let oldChild &#061; parentNode.removeChild(child);<\/p>\n<\/li>\n<li>\n<p>\u53c2\u6570\u53ca\u8bf4\u660e&#xff1a;<\/p>\n<ul>\n<li>\n<p>child&#xff1a;\u8981\u79fb\u9664\u7684\u5b50\u8282\u70b9\u3002<\/p>\n<\/li>\n<li>\n<p>\u8fd4\u56de\u503c&#xff1a;\u88ab\u79fb\u9664\u7684\u8282\u70b9&#xff08;\u4ecd\u5b58\u5728\u4e8e\u5185\u5b58\u4e2d&#xff0c;\u53ef\u4ee5\u540e\u7eed\u6dfb\u52a0&#xff09;\u3002<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u4f8b\u5b50&#xff1a;<\/p>\n<p>let parent &#061; document.getElementById(&#039;list&#039;);<br \/>\nlet lastItem &#061; document.getElementById(&#039;lastItem&#039;);<\/p>\n<p>\/\/ \u79fb\u9664\u6700\u540e\u4e00\u4e2a\u9879\u76ee<br \/>\nlet removedItem &#061; parent.removeChild(lastItem);<br \/>\nconsole.log(&#039;\u5df2\u79fb\u9664&#xff1a;&#039;, removedItem);<\/p>\n<p>\/\/ \u7a0d\u540e\u53ef\u4ee5\u91cd\u65b0\u6dfb\u52a0<br \/>\nparent.appendChild(removedItem);\n<\/li>\n<\/ul>\n<h3>12\u3001document.hasChildNodes()<\/h3>\n<ul>\n<li>\n<p>\u542b\u4e49&#xff1a;\u68c0\u67e5\u6587\u6863\u8282\u70b9\u662f\u5426\u6709\u5b50\u8282\u70b9\u3002<\/p>\n<\/li>\n<li>\n<p>\u8bcd\u6e90&#xff1a;Has&#xff08;\u6709&#xff09;&#043; Child&#xff08;\u5b69\u5b50&#xff09;&#043; Nodes&#xff08;\u8282\u70b9&#xff09;\u3002<\/p>\n<\/li>\n<li>\n<p>\u8bed\u6cd5&#xff1a;let hasChildren &#061; document.hasChildNodes();<\/p>\n<\/li>\n<li>\n<p>\u53c2\u6570\u53ca\u8bf4\u660e&#xff1a;\u65e0\u53c2\u6570\u3002<\/p>\n<\/li>\n<li>\n<p>\u8fd4\u56de\u503c&#xff1a;\u5e03\u5c14\u503c&#xff0c;\u6709\u5b50\u8282\u70b9\u8fd4\u56de\u00a0true&#xff0c;\u5426\u5219\u8fd4\u56de\u00a0false\u3002<\/p>\n<\/li>\n<li>\n<p>\u4f8b\u5b50&#xff1a;<\/p>\n<p>console.log(document.hasChildNodes()); \/\/ \u901a\u5e38\u8fd4\u56de true&#xff08;\u6709 doctype \u548c html&#xff09;<\/p>\n<p>\/\/ \u68c0\u67e5 body \u662f\u5426\u6709\u5b50\u8282\u70b9<br \/>\nconsole.log(document.body.hasChildNodes()); \/\/ \u53d6\u51b3\u4e8e\u9875\u9762\u5185\u5bb9\n<\/li>\n<\/ul>\n<h3>13\u3001document.normalize()<\/h3>\n<ul>\n<li>\n<p>\u542b\u4e49&#xff1a;\u89c4\u8303\u5316\u6587\u6863&#xff0c;\u5408\u5e76\u76f8\u90bb\u7684\u6587\u672c\u8282\u70b9\u5e76\u5220\u9664\u7a7a\u7684\u6587\u672c\u8282\u70b9\u3002<\/p>\n<\/li>\n<li>\n<p>\u8bcd\u6e90&#xff1a;Normalize&#xff08;\u6807\u51c6\u5316\u3001\u89c4\u8303\u5316&#xff09;\u3002<\/p>\n<\/li>\n<li>\n<p>\u8bed\u6cd5&#xff1a;document.normalize();<\/p>\n<\/li>\n<li>\n<p>\u53c2\u6570\u53ca\u8bf4\u660e&#xff1a;\u65e0\u53c2\u6570\u3002\u6e05\u7406\u6587\u6863\u6811\u7ed3\u6784\u3002<\/p>\n<\/li>\n<li>\n<p>\u4f8b\u5b50&#xff1a;<\/p>\n<p>let div &#061; document.createElement(&#039;div&#039;);<br \/>\ndiv.appendChild(document.createTextNode(&#039;Hello&#039;));<br \/>\ndiv.appendChild(document.createTextNode(&#039; &#039;));<br \/>\ndiv.appendChild(document.createTextNode(&#039;World&#039;));<\/p>\n<p>console.log(div.childNodes.length); \/\/ 3&#xff08;\u4e09\u4e2a\u6587\u672c\u8282\u70b9&#xff09;<\/p>\n<p>div.normalize();<br \/>\nconsole.log(div.childNodes.length); \/\/ 1&#xff08;\u5408\u5e76\u6210 &#034;Hello World&#034;&#xff09;\n<\/li>\n<\/ul>\n<h3>14\u3001document.prepend()<\/h3>\n<ul>\n<li>\n<p>\u542b\u4e49&#xff1a;\u5728\u6587\u6863\u7684\u7b2c\u4e00\u4e2a\u5b50\u8282\u70b9\u524d\u63d2\u5165\u4e00\u7ec4\u8282\u70b9\u6216\u5b57\u7b26\u4e32\u3002<\/p>\n<\/li>\n<li>\n<p>\u8bcd\u6e90&#xff1a;Prepend&#xff08;\u5728\u524d\u9762\u9644\u52a0&#xff09;\u3002<\/p>\n<\/li>\n<li>\n<p>\u8bed\u6cd5&#xff1a;document.prepend(&#8230;nodesOrStrings);<\/p>\n<\/li>\n<li>\n<p>\u53c2\u6570\u53ca\u8bf4\u660e&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u53ef\u4ee5\u63a5\u53d7\u591a\u4e2a\u53c2\u6570&#xff0c;\u53ef\u4ee5\u662f\u8282\u70b9\u5bf9\u8c61\u6216\u5b57\u7b26\u4e32\u3002<\/p>\n<\/li>\n<li>\n<p>\u5b57\u7b26\u4e32\u4f1a\u81ea\u52a8\u8f6c\u6362\u4e3a\u6587\u672c\u8282\u70b9\u3002<\/p>\n<\/li>\n<li>\n<p>\u6ce8\u610f&#xff1a;\u76f4\u63a5\u5bf9\u00a0document\u00a0\u4f7f\u7528\u00a0prepend\u00a0\u901a\u5e38\u4e0d\u5efa\u8bae&#xff0c;\u56e0\u4e3a\u6587\u6863\u53ea\u80fd\u6709\u4e00\u4e2a\u6839\u5143\u7d20\u3002\u8fd9\u4e2a\u65b9\u6cd5\u662f\u7ee7\u627f\u81ea\u00a0ParentNode\u00a0\u63a5\u53e3\u3002<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u4f8b\u5b50&#xff1a;<\/p>\n<p>\/\/ \u5728\u6587\u6863\u6700\u524d\u9762\u6dfb\u52a0\u6ce8\u91ca&#xff08;\u4e0d\u63a8\u8350\u76f4\u63a5\u5bf9 document \u4f7f\u7528&#xff09;<br \/>\n\/\/ \u66f4\u597d\u7684\u7528\u6cd5\u662f\u5bf9\u5177\u4f53\u5143\u7d20\u4f7f\u7528<br \/>\nlet list &#061; document.getElementById(&#039;myList&#039;);<br \/>\nlet firstItem &#061; document.createElement(&#039;li&#039;);<br \/>\nfirstItem.textContent &#061; &#039;\u65b0\u7684\u7b2c\u4e00\u9879&#039;;<br \/>\nlist.prepend(firstItem); \/\/ \u5728\u5217\u8868\u5f00\u5934\u6dfb\u52a0<\/p>\n<p>\/\/ \u53ef\u4ee5\u540c\u65f6\u6dfb\u52a0\u591a\u4e2a<br \/>\nlet p1 &#061; document.createElement(&#039;p&#039;);<br \/>\np1.textContent &#061; &#039;\u6bb5\u843d1&#039;;<br \/>\nlet p2 &#061; document.createElement(&#039;p&#039;);<br \/>\np2.textContent &#061; &#039;\u6bb5\u843d2&#039;;<br \/>\ndocument.body.prepend(p1, p2, &#039;\u6587\u672c\u5185\u5bb9&#039;); \/\/ \u5728 body \u5f00\u5934\u6dfb\u52a0\n<\/li>\n<\/ul>\n<h3>15\u3001document.append()<\/h3>\n<ul>\n<li>\n<p>\u542b\u4e49&#xff1a;\u5728\u6587\u6863\u7684\u6700\u540e\u4e00\u4e2a\u5b50\u8282\u70b9\u540e\u63d2\u5165\u4e00\u7ec4\u8282\u70b9\u6216\u5b57\u7b26\u4e32\u3002<\/p>\n<\/li>\n<li>\n<p>\u8bcd\u6e90&#xff1a;Append&#xff08;\u5728\u540e\u9762\u9644\u52a0&#xff09;\u3002<\/p>\n<\/li>\n<li>\n<p>\u8bed\u6cd5&#xff1a;document.append(&#8230;nodesOrStrings);<\/p>\n<\/li>\n<li>\n<p>\u53c2\u6570\u53ca\u8bf4\u660e&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u53ef\u4ee5\u63a5\u53d7\u591a\u4e2a\u53c2\u6570&#xff0c;\u53ef\u4ee5\u662f\u8282\u70b9\u5bf9\u8c61\u6216\u5b57\u7b26\u4e32\u3002<\/p>\n<\/li>\n<li>\n<p>\u5b57\u7b26\u4e32\u4f1a\u81ea\u52a8\u8f6c\u6362\u4e3a\u6587\u672c\u8282\u70b9\u3002<\/p>\n<\/li>\n<li>\n<p>\u4e0e\u00a0appendChild\u00a0\u4e0d\u540c&#xff0c;append\u00a0\u53ef\u4ee5\u63a5\u53d7\u591a\u4e2a\u53c2\u6570\u548c\u5b57\u7b26\u4e32\u3002<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u4f8b\u5b50&#xff1a;<\/p>\n<p>\/\/ \u5bf9 body \u4f7f\u7528<br \/>\nlet footer &#061; document.createElement(&#039;footer&#039;);<br \/>\nfooter.textContent &#061; &#039;\u7248\u6743\u4fe1\u606f&#039;;<br \/>\ndocument.body.append(footer, &#039;\u6587\u6863\u7ed3\u675f&#039;); \/\/ \u53ef\u4ee5\u540c\u65f6\u6dfb\u52a0\u5143\u7d20\u548c\u6587\u672c<\/p>\n<p>\/\/ \u5bf9\u6bd4 appendChild \u548c append<br \/>\nlet div &#061; document.getElementById(&#039;container&#039;);<\/p>\n<p>\/\/ appendChild&#xff1a;\u53ea\u80fd\u63a5\u53d7\u4e00\u4e2a\u8282\u70b9&#xff0c;\u4e0d\u80fd\u76f4\u63a5\u52a0\u5b57\u7b26\u4e32<br \/>\ndiv.appendChild(document.createTextNode(&#039;\u6587\u672c&#039;)); \/\/ \u9700\u8981\u5148\u521b\u5efa\u6587\u672c\u8282\u70b9<\/p>\n<p>\/\/ append&#xff1a;\u53ef\u4ee5\u76f4\u63a5\u52a0\u5b57\u7b26\u4e32&#xff0c;\u4e14\u53ef\u4ee5\u52a0\u591a\u4e2a<br \/>\ndiv.append(&#039;\u6587\u672c1&#039;, &#039;\u6587\u672c2&#039;, document.createElement(&#039;br&#039;));<\/p>\n<p>\/\/ \u8fd4\u56de\u503c\u4e0d\u540c<br \/>\nlet result1 &#061; div.appendChild(document.createElement(&#039;span&#039;)); \/\/ \u8fd4\u56de\u6dfb\u52a0\u7684\u8282\u70b9<br \/>\nlet result2 &#061; div.append(&#039;\u6587\u672c&#039;); \/\/ \u8fd4\u56de undefined\n<\/li>\n<\/ul>\n<h3>16\u3001document.replaceChildren()<\/h3>\n<ul>\n<li>\n<p>\u542b\u4e49&#xff1a;\u66ff\u6362\u6587\u6863\u7684\u6240\u6709\u5b50\u8282\u70b9&#xff08;\u6e05\u7a7a\u5e76\u6dfb\u52a0\u65b0\u8282\u70b9&#xff09;\u3002<\/p>\n<\/li>\n<li>\n<p>\u8bcd\u6e90&#xff1a;Replace&#xff08;\u66ff\u6362&#xff09;&#043; Children&#xff08;\u5b69\u5b50\u4eec&#xff09;\u3002<\/p>\n<\/li>\n<li>\n<p>\u8bed\u6cd5&#xff1a;document.replaceChildren(&#8230;nodesOrStrings);<\/p>\n<\/li>\n<li>\n<p>\u53c2\u6570\u53ca\u8bf4\u660e&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u53ef\u4ee5\u63a5\u53d7\u591a\u4e2a\u53c2\u6570&#xff0c;\u4f5c\u4e3a\u65b0\u7684\u5b50\u8282\u70b9\u3002<\/p>\n<\/li>\n<li>\n<p>\u5982\u679c\u4e0d\u4f20\u53c2\u6570&#xff0c;\u5219\u6e05\u7a7a\u6240\u6709\u5b50\u8282\u70b9\u3002<\/p>\n<\/li>\n<li>\n<p>\u5371\u9669\u64cd\u4f5c&#xff1a;\u76f4\u63a5\u5bf9\u00a0document\u00a0\u4f7f\u7528\u4f1a\u6e05\u7a7a\u6574\u4e2a\u6587\u6863\u3002<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u4f8b\u5b50&#xff1a;<\/p>\n<p>\/\/ \u5b89\u5168\u7528\u6cd5&#xff1a;\u5bf9\u5177\u4f53\u5143\u7d20\u4f7f\u7528<br \/>\nlet container &#061; document.getElementById(&#039;container&#039;);<\/p>\n<p>\/\/ \u6e05\u7a7a\u5bb9\u5668<br \/>\ncontainer.replaceChildren(); \/\/ \u79fb\u9664\u6240\u6709\u5b50\u8282\u70b9<\/p>\n<p>\/\/ \u66ff\u6362\u4e3a\u65b0\u5185\u5bb9<br \/>\nlet h2 &#061; document.createElement(&#039;h2&#039;);<br \/>\nh2.textContent &#061; &#039;\u65b0\u6807\u9898&#039;;<br \/>\nlet p &#061; document.createElement(&#039;p&#039;);<br \/>\np.textContent &#061; &#039;\u65b0\u6bb5\u843d&#039;;<br \/>\ncontainer.replaceChildren(h2, p, &#039;\u4e00\u4e9b\u6587\u672c&#039;);<\/p>\n<p>\/\/ \u5bf9\u6bd4 innerHTML &#061; &#039;&#039; \u548c replaceChildren()<br \/>\n\/\/ \u6027\u80fd\u66f4\u597d&#xff0c;\u4e14\u4e0d\u4f1a\u5bfc\u81f4\u5185\u5b58\u6cc4\u6f0f&#xff08;\u4e8b\u4ef6\u76d1\u542c\u5668\u4f1a\u88ab\u6b63\u786e\u6e05\u7406&#xff09;<\/p>\n<p>\/\/ \u5371\u9669\u793a\u8303&#xff08;\u4ec5\u7528\u4e8e\u7406\u89e3&#xff0c;\u4e0d\u8981\u6267\u884c&#xff09;<br \/>\n\/\/ document.replaceChildren(); \/\/ \u8fd9\u4f1a\u6e05\u7a7a\u6574\u4e2a\u9875\u9762&#xff01;\n<\/li>\n<\/ul>\n<hr \/>\n<h2>\u7b2c\u56db\u90e8\u5206&#xff1a;\u6587\u6863\u72b6\u6001\u4e0e\u4ea4\u4e92\u65b9\u6cd5&#xff08;10\u4e2a&#xff09;<\/h2>\n<h3>17\u3001document.hasFocus()<\/h3>\n<ul>\n<li>\n<p>\u542b\u4e49&#xff1a;\u8fd4\u56de\u4e00\u4e2a\u5e03\u5c14\u503c&#xff0c;\u8868\u793a\u6587\u6863\u662f\u5426\u83b7\u5f97\u7126\u70b9&#xff08;\u5373\u9875\u9762\u662f\u5426\u5904\u4e8e\u6d3b\u52a8\u72b6\u6001&#xff09;\u3002<\/p>\n<\/li>\n<li>\n<p>\u8bcd\u6e90&#xff1a;Has&#xff08;\u6709&#xff09;&#043; Focus&#xff08;\u7126\u70b9&#xff09;\u3002<\/p>\n<\/li>\n<li>\n<p>\u8bed\u6cd5&#xff1a;let focused &#061; document.hasFocus();<\/p>\n<\/li>\n<li>\n<p>\u53c2\u6570\u53ca\u8bf4\u660e&#xff1a;\u65e0\u53c2\u6570\u3002<\/p>\n<\/li>\n<li>\n<p>\u8fd4\u56de\u503c&#xff1a;\u5982\u679c\u6587\u6863\u83b7\u5f97\u7126\u70b9\u8fd4\u56de\u00a0true&#xff0c;\u5426\u5219\u8fd4\u56de\u00a0false\u3002<\/p>\n<\/li>\n<li>\n<p>\u4f8b\u5b50&#xff1a;<\/p>\n<p>\/\/ \u5b9e\u65f6\u76d1\u63a7\u9875\u9762\u7126\u70b9\u72b6\u6001<br \/>\nsetInterval(() &#061;&gt; {<br \/>\n    if (document.hasFocus()) {<br \/>\n        console.log(&#039;\u7528\u6237\u5728\u6d4f\u89c8\u5f53\u524d\u6807\u7b7e\u9875&#039;);<br \/>\n        \/\/ \u53ef\u4ee5\u6062\u590d\u52a8\u753b\u3001\u8f6e\u8be2\u7b49<br \/>\n    } else {<br \/>\n        console.log(&#039;\u7528\u6237\u5207\u6362\u5230\u5176\u4ed6\u6807\u7b7e\u9875&#039;);<br \/>\n        \/\/ \u53ef\u4ee5\u6682\u505c\u52a8\u753b\u3001\u964d\u4f4e\u8d44\u6e90\u6d88\u8017<br \/>\n    }<br \/>\n}, 1000);<\/p>\n<p>\/\/ \u79bb\u5f00\u9875\u9762\u65f6\u6682\u505c\u89c6\u9891<br \/>\ndocument.addEventListener(&#039;visibilitychange&#039;, function() {<br \/>\n    if (!document.hasFocus()) {<br \/>\n        let video &#061; document.getElementById(&#039;myVideo&#039;);<br \/>\n        if (video &amp;&amp; !video.paused) {<br \/>\n            video.pause();<br \/>\n        }<br \/>\n    }<br \/>\n});\n<\/li>\n<\/ul>\n<h3>18\u3001document.getElementById()<\/h3>\n<ul>\n<li>\n<p>\u542b\u4e49&#xff1a;\u901a\u8fc7\u5143\u7d20\u7684\u00a0id\u00a0\u5c5e\u6027\u83b7\u53d6\u5bf9\u5e94\u7684\u5143\u7d20\u5bf9\u8c61\u3002<\/p>\n<\/li>\n<li>\n<p>\u8bcd\u6e90&#xff1a;Get&#xff08;\u83b7\u53d6&#xff09;&#043; Element&#xff08;\u5143\u7d20&#xff09;&#043; By&#xff08;\u901a\u8fc7&#xff09;&#043; Id&#xff08;\u6807\u8bc6\u7b26&#xff09;\u3002<\/p>\n<\/li>\n<li>\n<p>\u8bed\u6cd5&#xff1a;let element &#061; document.getElementById(id);<\/p>\n<\/li>\n<li>\n<p>\u53c2\u6570\u53ca\u8bf4\u660e&#xff1a;<\/p>\n<ul>\n<li>\n<p>id&#xff1a;\u8981\u67e5\u627e\u7684\u5143\u7d20\u7684 ID \u5b57\u7b26\u4e32&#xff08;\u533a\u5206\u5927\u5c0f\u5199&#xff09;\u3002<\/p>\n<\/li>\n<li>\n<p>\u8fd4\u56de\u503c&#xff1a;\u627e\u5230\u7684\u00a0Element\u00a0\u5bf9\u8c61&#xff0c;\u5982\u679c\u6ca1\u6709\u627e\u5230\u5219\u8fd4\u56de\u00a0null\u3002<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u4f8b\u5b50&#xff1a;<\/p>\n<p>let header &#061; document.getElementById(&#039;main-header&#039;);<br \/>\nif (header) {<br \/>\n    header.style.backgroundColor &#061; &#039;yellow&#039;;<br \/>\n    header.textContent &#061; &#039;\u627e\u5230\u4e86\u6807\u9898&#039;;<br \/>\n} else {<br \/>\n    console.log(&#039;\u672a\u627e\u5230\u8be5\u5143\u7d20&#039;);<br \/>\n}\n<\/li>\n<\/ul>\n<h3>19\u3001document.getElementsByClassName()<\/h3>\n<ul>\n<li>\n<p>\u542b\u4e49&#xff1a;\u901a\u8fc7\u5143\u7d20\u7684\u7c7b\u540d\u83b7\u53d6\u4e00\u7ec4\u5143\u7d20\u5bf9\u8c61\u7684\u96c6\u5408&#xff08;\u5b9e\u65f6\u66f4\u65b0&#xff09;\u3002<\/p>\n<\/li>\n<li>\n<p>\u8bcd\u6e90&#xff1a;Get&#xff08;\u83b7\u53d6&#xff09;&#043; Elements&#xff08;\u5143\u7d20&#xff09;&#043; By&#xff08;\u901a\u8fc7&#xff09;&#043; Class&#xff08;\u7c7b&#xff09;&#043; Name&#xff08;\u540d\u79f0&#xff09;\u3002<\/p>\n<\/li>\n<li>\n<p>\u8bed\u6cd5&#xff1a;let elements &#061; document.getElementsByClassName(names);<\/p>\n<\/li>\n<li>\n<p>\u53c2\u6570\u53ca\u8bf4\u660e&#xff1a;<\/p>\n<ul>\n<li>\n<p>names&#xff1a;\u5305\u542b\u4e00\u4e2a\u6216\u591a\u4e2a\u7c7b\u540d\u7684\u5b57\u7b26\u4e32&#xff08;\u7528\u7a7a\u683c\u5206\u9694&#xff09;\u3002<\/p>\n<\/li>\n<li>\n<p>\u8fd4\u56de\u503c&#xff1a;\u5b9e\u65f6\u7684\u00a0HTMLCollection\u00a0\u96c6\u5408\u3002<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u4f8b\u5b50&#xff1a;<\/p>\n<p>\/\/ \u83b7\u53d6\u6240\u6709 class&#061;&#034;item&#034; \u7684\u5143\u7d20<br \/>\nlet items &#061; document.getElementsByClassName(&#039;item&#039;);<br \/>\nconsole.log(&#039;\u627e\u5230&#039;, items.length, &#039;\u4e2a\u9879\u76ee&#039;);<\/p>\n<p>\/\/ \u904d\u5386\u5e76\u4fee\u6539\u6837\u5f0f<br \/>\nfor (let item of items) {<br \/>\n    item.style.border &#061; &#039;1px solid black&#039;;<br \/>\n}<\/p>\n<p>\/\/ \u540c\u65f6\u5339\u914d\u591a\u4e2a\u7c7b\u540d<br \/>\nlet activeItems &#061; document.getElementsByClassName(&#039;item active&#039;);\n<\/li>\n<\/ul>\n<h3>20\u3001document.getElementsByName()<\/h3>\n<ul>\n<li>\n<p>\u542b\u4e49&#xff1a;\u901a\u8fc7\u5143\u7d20\u7684\u00a0name\u00a0\u5c5e\u6027\u83b7\u53d6\u4e00\u7ec4\u5143\u7d20\u5bf9\u8c61\u7684\u96c6\u5408\u3002<\/p>\n<\/li>\n<li>\n<p>\u8bcd\u6e90&#xff1a;Get&#xff08;\u83b7\u53d6&#xff09;&#043; Elements&#xff08;\u5143\u7d20&#xff09;&#043; By&#xff08;\u901a\u8fc7&#xff09;&#043; Name&#xff08;\u540d\u79f0&#xff09;\u3002<\/p>\n<\/li>\n<li>\n<p>\u8bed\u6cd5&#xff1a;let elements &#061; document.getElementsByName(name);<\/p>\n<\/li>\n<li>\n<p>\u53c2\u6570\u53ca\u8bf4\u660e&#xff1a;<\/p>\n<ul>\n<li>\n<p>name&#xff1a;\u8981\u67e5\u627e\u7684\u00a0name\u00a0\u5c5e\u6027\u503c\u3002<\/p>\n<\/li>\n<li>\n<p>\u8fd4\u56de\u503c&#xff1a;NodeList\u00a0\u96c6\u5408&#xff08;\u975e\u5b9e\u65f6&#xff0c;\u9759\u6001\u5feb\u7167&#xff09;\u3002<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u4f8b\u5b50&#xff1a;<\/p>\n<p>\/\/ \u5e38\u7528\u4e8e\u8868\u5355\u5143\u7d20<br \/>\nlet genderRadios &#061; document.getElementsByName(&#039;gender&#039;);<\/p>\n<p>\/\/ \u627e\u51fa\u9009\u4e2d\u7684\u5355\u9009\u6309\u94ae<br \/>\nlet selectedGender &#061; null;<br \/>\nfor (let radio of genderRadios) {<br \/>\n    if (radio.checked) {<br \/>\n        selectedGender &#061; radio.value;<br \/>\n        break;<br \/>\n    }<br \/>\n}<br \/>\nconsole.log(&#039;\u9009\u4e2d\u7684\u6027\u522b&#xff1a;&#039;, selectedGender);\n<\/li>\n<\/ul>\n<h3>21\u3001document.getElementsByTagName()<\/h3>\n<ul>\n<li>\n<p>\u542b\u4e49&#xff1a;\u901a\u8fc7\u6807\u7b7e\u540d\u83b7\u53d6\u4e00\u7ec4\u5143\u7d20\u5bf9\u8c61\u7684\u96c6\u5408&#xff08;\u5b9e\u65f6\u66f4\u65b0&#xff09;\u3002<\/p>\n<\/li>\n<li>\n<p>\u8bcd\u6e90&#xff1a;Get&#xff08;\u83b7\u53d6&#xff09;&#043; Elements&#xff08;\u5143\u7d20&#xff09;&#043; By&#xff08;\u901a\u8fc7&#xff09;&#043; Tag&#xff08;\u6807\u7b7e&#xff09;&#043; Name&#xff08;\u540d\u79f0&#xff09;\u3002<\/p>\n<\/li>\n<li>\n<p>\u8bed\u6cd5&#xff1a;let elements &#061; document.getElementsByTagName(tagName);<\/p>\n<\/li>\n<li>\n<p>\u53c2\u6570\u53ca\u8bf4\u660e&#xff1a;<\/p>\n<ul>\n<li>\n<p>tagName&#xff1a;\u6807\u7b7e\u540d&#xff08;\u5982\u00a0&#039;div&#039;\u3001&#039;p&#039;&#xff09;\u3002\u7279\u6b8a\u503c\u00a0&#039;*&#039;\u00a0\u5339\u914d\u6240\u6709\u5143\u7d20\u3002<\/p>\n<\/li>\n<li>\n<p>\u8fd4\u56de\u503c&#xff1a;\u5b9e\u65f6\u7684\u00a0HTMLCollection\u3002<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u4f8b\u5b50&#xff1a;<\/p>\n<p>let paragraphs &#061; document.getElementsByTagName(&#039;p&#039;);<br \/>\nconsole.log(&#039;\u9875\u9762\u4e2d\u6709&#039;, paragraphs.length, &#039;\u4e2a\u6bb5\u843d&#039;);<\/p>\n<p>\/\/ \u5c06\u6240\u6709\u6bb5\u843d\u6587\u5b57\u53d8\u84dd<br \/>\nfor (let p of paragraphs) {<br \/>\n    p.style.color &#061; &#039;blue&#039;;<br \/>\n}<\/p>\n<p>\/\/ \u83b7\u53d6\u6240\u6709\u5143\u7d20<br \/>\nlet allElements &#061; document.getElementsByTagName(&#039;*&#039;);<br \/>\nconsole.log(&#039;\u603b\u5143\u7d20\u6570&#xff1a;&#039;, allElements.length);\n<\/li>\n<\/ul>\n<h3>22\u3001document.getElementsByTagNameNS()<\/h3>\n<ul>\n<li>\n<p>\u542b\u4e49&#xff1a;\u901a\u8fc7\u6807\u7b7e\u540d\u548c\u547d\u540d\u7a7a\u95f4 URI \u83b7\u53d6\u5143\u7d20\u96c6\u5408\u3002<\/p>\n<\/li>\n<li>\n<p>\u8bcd\u6e90&#xff1a;Get&#xff08;\u83b7\u53d6&#xff09;&#043; Elements&#xff08;\u5143\u7d20&#xff09;&#043; By&#xff08;\u901a\u8fc7&#xff09;&#043; TagName&#xff08;\u6807\u7b7e\u540d&#xff09;&#043; NS&#xff08;\u547d\u540d\u7a7a\u95f4&#xff09;\u3002<\/p>\n<\/li>\n<li>\n<p>\u8bed\u6cd5&#xff1a;let elements &#061; document.getElementsByTagNameNS(namespaceURI, localName);<\/p>\n<\/li>\n<li>\n<p>\u53c2\u6570\u53ca\u8bf4\u660e&#xff1a;<\/p>\n<ul>\n<li>\n<p>namespaceURI&#xff1a;\u547d\u540d\u7a7a\u95f4 URI&#xff08;\u5982 SVG \u7684\u00a0&#039;http:\/\/www.w3.org\/2000\/svg&#039;&#xff09;\u3002<\/p>\n<\/li>\n<li>\n<p>localName&#xff1a;\u672c\u5730\u6807\u7b7e\u540d&#xff08;\u5982\u00a0&#039;svg&#039;\u3001&#039;circle&#039;&#xff09;\u3002&#039;*&#039;\u00a0\u5339\u914d\u6240\u6709\u3002<\/p>\n<\/li>\n<li>\n<p>\u8fd4\u56de\u503c&#xff1a;\u5b9e\u65f6\u7684\u00a0NodeList\u3002<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u4f8b\u5b50&#xff1a;<\/p>\n<p>\/\/ \u83b7\u53d6\u6240\u6709 SVG \u5143\u7d20<br \/>\nlet svgElements &#061; document.getElementsByTagNameNS(<br \/>\n    &#039;http:\/\/www.w3.org\/2000\/svg&#039;,<br \/>\n    &#039;*&#039;<br \/>\n);<br \/>\nconsole.log(&#039;SVG \u5143\u7d20\u6570\u91cf&#xff1a;&#039;, svgElements.length);<\/p>\n<p>\/\/ \u83b7\u53d6\u6240\u6709 circle \u5143\u7d20<br \/>\nlet circles &#061; document.getElementsByTagNameNS(<br \/>\n    &#039;http:\/\/www.w3.org\/2000\/svg&#039;,<br \/>\n    &#039;circle&#039;<br \/>\n);\n<\/li>\n<\/ul>\n<h3>23\u3001document.querySelector()<\/h3>\n<ul>\n<li>\n<p>\u542b\u4e49&#xff1a;\u8fd4\u56de\u6587\u6863\u4e2d\u5339\u914d\u6307\u5b9a CSS \u9009\u62e9\u5668\u7684\u7b2c\u4e00\u4e2a\u5143\u7d20\u3002<\/p>\n<\/li>\n<li>\n<p>\u8bcd\u6e90&#xff1a;Query&#xff08;\u67e5\u8be2&#xff09;&#043; Selector&#xff08;\u9009\u62e9\u5668&#xff09;\u3002<\/p>\n<\/li>\n<li>\n<p>\u8bed\u6cd5&#xff1a;let element &#061; document.querySelector(selectors);<\/p>\n<\/li>\n<li>\n<p>\u53c2\u6570\u53ca\u8bf4\u660e&#xff1a;<\/p>\n<ul>\n<li>\n<p>selectors&#xff1a;\u4e00\u4e2a\u6709\u6548\u7684 CSS \u9009\u62e9\u5668\u5b57\u7b26\u4e32\u3002<\/p>\n<\/li>\n<li>\n<p>\u8fd4\u56de\u503c&#xff1a;\u5339\u914d\u7684\u7b2c\u4e00\u4e2a\u5143\u7d20&#xff0c;\u6ca1\u6709\u5219\u8fd4\u56de\u00a0null\u3002<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u4f8b\u5b50&#xff1a;<\/p>\n<p>let firstButton &#061; document.querySelector(&#039;button.primary&#039;);<br \/>\nlet header &#061; document.querySelector(&#039;#header &gt; nav .menu-item&#039;);<br \/>\nlet complex &#061; document.querySelector(&#039;div[data-type&#061;&#034;user&#034;]:nth-child(2)&#039;);<\/p>\n<p>if (firstButton) {<br \/>\n    firstButton.click(); \/\/ \u81ea\u52a8\u70b9\u51fb\u7b2c\u4e00\u4e2a\u6309\u94ae<br \/>\n}\n<\/li>\n<\/ul>\n<h3>24\u3001document.querySelectorAll()<\/h3>\n<ul>\n<li>\n<p>\u542b\u4e49&#xff1a;\u8fd4\u56de\u6587\u6863\u4e2d\u5339\u914d\u6307\u5b9a CSS \u9009\u62e9\u5668\u7684\u6240\u6709\u5143\u7d20\u7684\u9759\u6001\u96c6\u5408\u3002<\/p>\n<\/li>\n<li>\n<p>\u8bcd\u6e90&#xff1a;Query&#xff08;\u67e5\u8be2&#xff09;&#043; Selector All&#xff08;\u6240\u6709\u9009\u62e9\u5668&#xff09;\u3002<\/p>\n<\/li>\n<li>\n<p>\u8bed\u6cd5&#xff1a;let elementList &#061; document.querySelectorAll(selectors);<\/p>\n<\/li>\n<li>\n<p>\u53c2\u6570\u53ca\u8bf4\u660e&#xff1a;<\/p>\n<ul>\n<li>\n<p>selectors&#xff1a;CSS \u9009\u62e9\u5668\u5b57\u7b26\u4e32\u3002<\/p>\n<\/li>\n<li>\n<p>\u8fd4\u56de\u503c&#xff1a;\u9759\u6001\u7684\u00a0NodeList&#xff08;\u652f\u6301\u00a0forEach\u00a0\u65b9\u6cd5&#xff09;\u3002<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u4f8b\u5b50&#xff1a;<\/p>\n<p>let items &#061; document.querySelectorAll(&#039;.list-item&#039;);<br \/>\nconsole.log(&#039;\u627e\u5230&#039;, items.length, &#039;\u4e2a\u9879\u76ee&#039;);<\/p>\n<p>\/\/ \u4f7f\u7528 forEach \u904d\u5386<br \/>\nitems.forEach((item, index) &#061;&gt; {<br \/>\n    item.textContent &#061; &#096;\u9879\u76ee ${index &#043; 1}&#096;;<br \/>\n});<\/p>\n<p>\/\/ \u590d\u6742\u9009\u62e9\u5668<br \/>\nlet checkedItems &#061; document.querySelectorAll(<br \/>\n    &#039;input[type&#061;&#034;checkbox&#034;]:checked, input[type&#061;&#034;radio&#034;]:checked&#039;<br \/>\n);\n<\/li>\n<\/ul>\n<h3>25\u3001document.getSelection()<\/h3>\n<ul>\n<li>\n<p>\u542b\u4e49&#xff1a;\u8fd4\u56de\u7528\u6237\u5f53\u524d\u5728\u9875\u9762\u4e0a\u9009\u4e2d\u7684\u6587\u672c\u8303\u56f4\u3002<\/p>\n<\/li>\n<li>\n<p>\u8bcd\u6e90&#xff1a;Get&#xff08;\u83b7\u53d6&#xff09;&#043; Selection&#xff08;\u9009\u62e9&#xff09;\u3002<\/p>\n<\/li>\n<li>\n<p>\u8bed\u6cd5&#xff1a;let selection &#061; document.getSelection();<\/p>\n<\/li>\n<li>\n<p>\u53c2\u6570\u53ca\u8bf4\u660e&#xff1a;\u65e0\u53c2\u6570\u3002<\/p>\n<\/li>\n<li>\n<p>\u8fd4\u56de\u503c&#xff1a;Selection\u00a0\u5bf9\u8c61&#xff0c;\u5305\u542b\u9009\u4e2d\u533a\u57df\u7684\u4fe1\u606f\u548c\u65b9\u6cd5\u3002<\/p>\n<\/li>\n<li>\n<p>\u4f8b\u5b50&#xff1a;<\/p>\n<p>\/\/ \u76d1\u542c\u9f20\u6807\u677e\u5f00\u4e8b\u4ef6&#xff0c;\u83b7\u53d6\u9009\u4e2d\u7684\u6587\u672c<br \/>\ndocument.addEventListener(&#039;mouseup&#039;, function() {<br \/>\n    let selection &#061; document.getSelection();<br \/>\n    let selectedText &#061; selection.toString();<\/p>\n<p>    if (selectedText) {<br \/>\n        console.log(&#039;\u9009\u4e2d\u4e86&#xff1a;&#039;, selectedText);<br \/>\n        console.log(&#039;\u957f\u5ea6&#xff1a;&#039;, selectedText.length);<br \/>\n        console.log(&#039;\u8d77\u59cb\u4f4d\u7f6e&#xff1a;&#039;, selection.anchorOffset);<br \/>\n        console.log(&#039;\u7ed3\u675f\u4f4d\u7f6e&#xff1a;&#039;, selection.focusOffset);<br \/>\n    }<br \/>\n});<\/p>\n<p>\/\/ \u624b\u52a8\u83b7\u53d6\u5e76\u64cd\u4f5c\u9009\u4e2d\u6587\u672c<br \/>\nfunction getSelectedHtml() {<br \/>\n    let selection &#061; document.getSelection();<br \/>\n    if (selection.rangeCount &gt; 0) {<br \/>\n        let range &#061; selection.getRangeAt(0);<br \/>\n        let fragment &#061; range.cloneContents();<br \/>\n        let div &#061; document.createElement(&#039;div&#039;);<br \/>\n        div.appendChild(fragment);<br \/>\n        return div.innerHTML;<br \/>\n    }<br \/>\n    return &#039;&#039;;<br \/>\n}\n<\/li>\n<\/ul>\n<h3>26\u3001document.exitFullscreen()<\/h3>\n<ul>\n<li>\n<p>\u542b\u4e49&#xff1a;\u9000\u51fa\u5168\u5c4f\u6a21\u5f0f&#xff0c;\u5c06\u6587\u6863\u6062\u590d\u5230\u6b63\u5e38\u663e\u793a\u72b6\u6001\u3002<\/p>\n<\/li>\n<li>\n<p>\u8bcd\u6e90&#xff1a;Exit&#xff08;\u9000\u51fa&#xff09;&#043; Fullscreen&#xff08;\u5168\u5c4f&#xff09;\u3002<\/p>\n<\/li>\n<li>\n<p>\u8bed\u6cd5&#xff1a;let promise &#061; document.exitFullscreen();<\/p>\n<\/li>\n<li>\n<p>\u53c2\u6570\u53ca\u8bf4\u660e&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u65e0\u53c2\u6570\u3002<\/p>\n<\/li>\n<li>\n<p>\u8fd4\u56de\u503c&#xff1a;\u4e00\u4e2a Promise&#xff0c;\u5728\u5168\u5c4f\u9000\u51fa\u6210\u529f\u540e resolved&#xff0c;\u5931\u8d25\u65f6 rejected\u3002<\/p>\n<\/li>\n<li>\n<p>\u901a\u5e38\u4e0e\u00a0document.fullscreenElement\u00a0\u914d\u5408\u4f7f\u7528\u3002<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u4f8b\u5b50&#xff1a;<\/p>\n<p>\/\/ \u9000\u51fa\u5168\u5c4f\u6309\u94ae<br \/>\nlet exitBtn &#061; document.getElementById(&#039;exit-fullscreen&#039;);<br \/>\nexitBtn.addEventListener(&#039;click&#039;, function() {<br \/>\n    if (document.fullscreenElement) {<br \/>\n        document.exitFullscreen()<br \/>\n            .then(() &#061;&gt; console.log(&#039;\u6210\u529f\u9000\u51fa\u5168\u5c4f&#039;))<br \/>\n            .catch((err) &#061;&gt; {<br \/>\n                console.error(&#039;\u9000\u51fa\u5168\u5c4f\u5931\u8d25:&#039;, err);<br \/>\n                alert(&#039;\u9000\u51fa\u5168\u5c4f\u5931\u8d25&#xff1a;&#039; &#043; err.message);<br \/>\n            });<br \/>\n    }<br \/>\n});<\/p>\n<p>\/\/ \u6309 ESC \u952e\u65f6\u81ea\u52a8\u9000\u51fa\u5168\u5c4f&#xff08;\u6d4f\u89c8\u5668\u9ed8\u8ba4\u884c\u4e3a&#xff0c;\u8fd9\u91cc\u53ea\u662f\u6f14\u793a&#xff09;<br \/>\ndocument.addEventListener(&#039;fullscreenchange&#039;, function() {<br \/>\n    if (!document.fullscreenElement) {<br \/>\n        console.log(&#039;\u5df2\u9000\u51fa\u5168\u5c4f\u6a21\u5f0f&#039;);<br \/>\n        \/\/ \u6062\u590d\u4e00\u4e9b UI \u72b6\u6001<br \/>\n        document.body.classList.remove(&#039;fullscreen-mode&#039;);<br \/>\n    } else {<br \/>\n        document.body.classList.add(&#039;fullscreen-mode&#039;);<br \/>\n    }<br \/>\n});<\/p>\n<p>\/\/ \u5168\u5c4f\u5207\u6362\u51fd\u6570<br \/>\nasync function toggleFullscreen(element) {<br \/>\n    if (!document.fullscreenElement) {<br \/>\n        \/\/ \u8fdb\u5165\u5168\u5c4f<br \/>\n        await element.requestFullscreen();<br \/>\n    } else {<br \/>\n        \/\/ \u9000\u51fa\u5168\u5c4f<br \/>\n        await document.exitFullscreen();<br \/>\n    }<br \/>\n}\n<\/li>\n<\/ul>\n<hr \/>\n<h2>\u7b2c\u4e94\u90e8\u5206&#xff1a;\u5750\u6807\u4e0e\u8303\u56f4\u65b9\u6cd5&#xff08;6\u4e2a&#xff09;<\/h2>\n<h3>27\u3001document.elementFromPoint()<\/h3>\n<ul>\n<li>\n<p>\u542b\u4e49&#xff1a;\u8fd4\u56de\u5728\u9875\u9762\u6307\u5b9a\u5750\u6807\u5904\u6700\u9876\u5c42\u7684\u5143\u7d20\u3002<\/p>\n<\/li>\n<li>\n<p>\u8bcd\u6e90&#xff1a;Element&#xff08;\u5143\u7d20&#xff09;&#043; From&#xff08;\u4ece&#xff09;&#043; Point&#xff08;\u70b9&#xff09;\u3002<\/p>\n<\/li>\n<li>\n<p>\u8bed\u6cd5&#xff1a;let element &#061; document.elementFromPoint(x, y);<\/p>\n<\/li>\n<li>\n<p>\u53c2\u6570\u53ca\u8bf4\u660e&#xff1a;<\/p>\n<ul>\n<li>\n<p>x&#xff1a;\u76f8\u5bf9\u4e8e\u89c6\u53e3\u7684\u6c34\u5e73\u5750\u6807&#xff08;\u50cf\u7d20&#xff09;\u3002<\/p>\n<\/li>\n<li>\n<p>y&#xff1a;\u76f8\u5bf9\u4e8e\u89c6\u53e3\u7684\u5782\u76f4\u5750\u6807&#xff08;\u50cf\u7d20&#xff09;\u3002<\/p>\n<\/li>\n<li>\n<p>\u8fd4\u56de\u503c&#xff1a;\u6307\u5b9a\u5750\u6807\u5904\u7684\u00a0Element&#xff0c;\u5982\u679c\u5750\u6807\u5728\u89c6\u53e3\u5916\u5219\u8fd4\u56de\u00a0null\u3002<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u4f8b\u5b50&#xff1a;<\/p>\n<p>\/\/ \u83b7\u53d6\u5c4f\u5e55\u4e2d\u5fc3\u70b9\u7684\u5143\u7d20<br \/>\nlet centerX &#061; window.innerWidth \/ 2;<br \/>\nlet centerY &#061; window.innerHeight \/ 2;<br \/>\nlet centerElement &#061; document.elementFromPoint(centerX, centerY);<br \/>\nconsole.log(&#039;\u5c4f\u5e55\u4e2d\u5fc3\u70b9\u7684\u5143\u7d20&#xff1a;&#039;, centerElement.tagName);<\/p>\n<p>\/\/ \u76d1\u542c\u70b9\u51fb&#xff0c;\u5e76\u83b7\u53d6\u70b9\u51fb\u5904\u7684\u5143\u7d20&#xff08;\u5373\u4f7f\u6709\u4e8b\u4ef6\u5192\u6ce1\u4e5f\u80fd\u83b7\u53d6\u6700\u4e0a\u5c42\u5143\u7d20&#xff09;<br \/>\ndocument.addEventListener(&#039;click&#039;, function(event) {<br \/>\n    let elemAtPoint &#061; document.elementFromPoint(event.clientX, event.clientY);<br \/>\n    console.log(&#039;\u70b9\u51fb\u5904\u6700\u4e0a\u5c42\u7684\u5143\u7d20&#xff1a;&#039;, elemAtPoint.tagName, elemAtPoint.className);<br \/>\n});\n<\/li>\n<\/ul>\n<h3>28\u3001document.elementsFromPoint()<\/h3>\n<ul>\n<li>\n<p>\u542b\u4e49&#xff1a;\u8fd4\u56de\u5728\u9875\u9762\u6307\u5b9a\u5750\u6807\u5904\u6240\u6709\u5143\u7d20\u7684\u6570\u7ec4&#xff08;\u4ece\u6700\u9876\u5c42\u5230\u6700\u5e95\u5c42&#xff09;\u3002<\/p>\n<\/li>\n<li>\n<p>\u8bcd\u6e90&#xff1a;Elements&#xff08;\u5143\u7d20&#xff09;&#043; From&#xff08;\u4ece&#xff09;&#043; Point&#xff08;\u70b9&#xff09;\u3002<\/p>\n<\/li>\n<li>\n<p>\u8bed\u6cd5&#xff1a;let elements &#061; document.elementsFromPoint(x, y);<\/p>\n<\/li>\n<li>\n<p>\u53c2\u6570\u53ca\u8bf4\u660e&#xff1a;<\/p>\n<ul>\n<li>\n<p>x&#xff1a;\u76f8\u5bf9\u4e8e\u89c6\u53e3\u7684\u6c34\u5e73\u5750\u6807\u3002<\/p>\n<\/li>\n<li>\n<p>y&#xff1a;\u76f8\u5bf9\u4e8e\u89c6\u53e3\u7684\u5782\u76f4\u5750\u6807\u3002<\/p>\n<\/li>\n<li>\n<p>\u8fd4\u56de\u503c&#xff1a;\u5305\u542b\u6240\u6709\u91cd\u53e0\u5143\u7d20\u7684\u6570\u7ec4&#xff0c;\u6309 z-index \u4ece\u9ad8\u5230\u4f4e\u6392\u5217\u3002<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u4f8b\u5b50&#xff1a;<\/p>\n<p>document.addEventListener(&#039;mousemove&#039;, function(event) {<br \/>\n    let elements &#061; document.elementsFromPoint(event.clientX, event.clientY);<\/p>\n<p>    \/\/ \u663e\u793a\u9f20\u6807\u4e0b\u65b9\u7684\u6240\u6709\u5143\u7d20<br \/>\n    let tagNames &#061; elements.map(el &#061;&gt; el.tagName).join(&#039; \u2192 &#039;);<br \/>\n    console.log(&#039;\u9f20\u6807\u4e0b\u65b9\u5143\u7d20\u5c42\u7ea7&#xff1a;&#039;, tagNames);<\/p>\n<p>    \/\/ \u8c03\u8bd5&#xff1a;\u9ad8\u4eae\u6240\u6709\u5143\u7d20<br \/>\n    elements.forEach((el, index) &#061;&gt; {<br \/>\n        el.style.outline &#061; index &#061;&#061;&#061; 0 ? &#039;2px solid red&#039; : &#039;1px dashed blue&#039;;<br \/>\n    });<br \/>\n});<\/p>\n<p>\/\/ \u68c0\u67e5\u67d0\u4e2a\u4f4d\u7f6e\u662f\u5426\u6709\u7279\u5b9a\u5143\u7d20<br \/>\nfunction hasElementAtPoint(x, y, selector) {<br \/>\n    let elements &#061; document.elementsFromPoint(x, y);<br \/>\n    return elements.some(el &#061;&gt; el.matches(selector));<br \/>\n}\n<\/li>\n<\/ul>\n<h3>29\u3001document.getClientRects()<\/h3>\n<ul>\n<li>\n<p>\u542b\u4e49&#xff1a;\u8fd4\u56de\u5143\u7d20\u5728\u9875\u9762\u4e0a\u5360\u636e\u7684\u6240\u6709\u77e9\u5f62\u533a\u57df&#xff08;\u901a\u5e38\u7528\u4e8e\u83b7\u53d6\u5185\u8054\u5143\u7d20\u7684\u6362\u884c\u4fe1\u606f&#xff09;\u3002<\/p>\n<\/li>\n<li>\n<p>\u8bcd\u6e90&#xff1a;Get&#xff08;\u83b7\u53d6&#xff09;&#043; Client&#xff08;\u5ba2\u6237\u7aef&#xff09;&#043; Rects&#xff08;\u77e9\u5f62&#xff09;\u3002<\/p>\n<\/li>\n<li>\n<p>\u8bed\u6cd5&#xff1a;let rectCollection &#061; element.getClientRects();<\/p>\n<\/li>\n<li>\n<p>\u53c2\u6570\u53ca\u8bf4\u660e&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u8fd9\u4e2a\u65b9\u6cd5\u901a\u5e38\u5728\u5177\u4f53\u7684\u5143\u7d20\u4e0a\u8c03\u7528&#xff0c;\u800c\u4e0d\u662f\u00a0document\u3002<\/p>\n<\/li>\n<li>\n<p>\u8fd4\u56de\u503c&#xff1a;DOMRectList\u00a0\u5bf9\u8c61&#xff0c;\u5305\u542b\u4e00\u4e2a\u6216\u591a\u4e2a\u00a0DOMRect\u00a0\u5bf9\u8c61\u3002<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u4f8b\u5b50&#xff1a;<\/p>\n<p>\/\/ \u6ce8\u610f&#xff1a;\u8fd9\u4e2a\u65b9\u6cd5\u5c5e\u4e8e Element&#xff0c;\u4f46\u8fd9\u91cc\u5217\u51fa\u662f\u56e0\u4e3a\u4f60\u63d0\u5230\u4e86<br \/>\nlet textSpan &#061; document.getElementById(&#039;multi-line-text&#039;);<\/p>\n<p>\/\/ \u83b7\u53d6\u5185\u8054\u5143\u7d20\u7684\u6240\u6709\u77e9\u5f62&#xff08;\u4f8b\u5982\u6362\u884c\u540e\u4f1a\u6709\u591a\u4e2a\u77e9\u5f62&#xff09;<br \/>\nlet rects &#061; textSpan.getClientRects();<\/p>\n<p>console.log(&#039;\u8fd9\u4e2a\u5143\u7d20\u5360\u636e&#039;, rects.length, &#039;\u4e2a\u77e9\u5f62\u533a\u57df&#039;);<\/p>\n<p>for (let i &#061; 0; i &lt; rects.length; i&#043;&#043;) {<br \/>\n    let rect &#061; rects[i];<br \/>\n    console.log(&#096;\u77e9\u5f62 ${i &#043; 1}:&#096;, {<br \/>\n        left: rect.left,<br \/>\n        top: rect.top,<br \/>\n        right: rect.right,<br \/>\n        bottom: rect.bottom,<br \/>\n        width: rect.width,<br \/>\n        height: rect.height<br \/>\n    });<br \/>\n}<\/p>\n<p>\/\/ \u5224\u65ad\u6587\u672c\u662f\u5426\u6362\u884c<br \/>\nif (rects.length &gt; 1) {<br \/>\n    console.log(&#039;\u6587\u672c\u6362\u884c\u4e86&#039;);<br \/>\n}\n<\/li>\n<\/ul>\n<h3>30\u3001document.createRange()<\/h3>\n<ul>\n<li>\n<p>\u542b\u4e49&#xff1a;\u521b\u5efa\u4e00\u4e2a\u65b0\u7684 Range \u5bf9\u8c61&#xff0c;\u8868\u793a\u6587\u6863\u4e2d\u7684\u4e00\u4e2a\u8fde\u7eed\u533a\u57df\u3002<\/p>\n<\/li>\n<li>\n<p>\u8bcd\u6e90&#xff1a;Create&#xff08;\u521b\u5efa&#xff09;&#043; Range&#xff08;\u8303\u56f4&#xff09;\u3002<\/p>\n<\/li>\n<li>\n<p>\u8bed\u6cd5&#xff1a;let range &#061; document.createRange();<\/p>\n<\/li>\n<li>\n<p>\u53c2\u6570\u53ca\u8bf4\u660e&#xff1a;\u65e0\u53c2\u6570\u3002\u8fd4\u56de\u4e00\u4e2a\u521d\u59cb\u5316\u7684\u7a7a\u00a0Range\u00a0\u5bf9\u8c61\u3002<\/p>\n<\/li>\n<li>\n<p>\u4f8b\u5b50&#xff1a;<\/p>\n<p>\/\/ \u521b\u5efa\u8303\u56f4<br \/>\nlet range &#061; document.createRange();<\/p>\n<p>\/\/ \u8bbe\u7f6e\u8303\u56f4\u7684\u8d77\u70b9\u548c\u7ec8\u70b9<br \/>\nlet startNode &#061; document.getElementById(&#039;start&#039;);<br \/>\nlet endNode &#061; document.getElementById(&#039;end&#039;);<\/p>\n<p>\/\/ \u4ece startNode \u7684\u7b2c 2 \u4e2a\u5b50\u8282\u70b9\u5f00\u59cb&#xff0c;\u504f\u79fb\u91cf\u4e3a 0<br \/>\nrange.setStart(startNode, 2);<br \/>\n\/\/ \u5230 endNode \u7684\u7b2c 1 \u4e2a\u5b50\u8282\u70b9\u7ed3\u675f&#xff0c;\u504f\u79fb\u91cf\u4e3a 3<br \/>\nrange.setEnd(endNode, 1);<\/p>\n<p>\/\/ \u83b7\u53d6\u8303\u56f4\u5185\u7684\u5185\u5bb9<br \/>\nlet fragment &#061; range.cloneContents(); \/\/ \u514b\u9686\u5185\u5bb9<br \/>\nlet selectedText &#061; range.toString(); \/\/ \u83b7\u53d6\u7eaf\u6587\u672c<\/p>\n<p>console.log(&#039;\u9009\u4e2d\u6587\u672c&#xff1a;&#039;, selectedText);<\/p>\n<p>\/\/ \u9ad8\u4eae\u9009\u4e2d\u7684\u8303\u56f4<br \/>\nlet highlightSpan &#061; document.createElement(&#039;span&#039;);<br \/>\nhighlightSpan.style.backgroundColor &#061; &#039;yellow&#039;;<br \/>\nrange.surroundContents(highlightSpan); \/\/ \u7528 span \u5305\u88f9\u8303\u56f4\u5185\u5bb9<\/p>\n<p>\/\/ \u66f4\u7b80\u5355\u7684\u7528\u6cd5&#xff1a;\u9009\u4e2d\u6574\u4e2a\u5143\u7d20\u5185\u5bb9<br \/>\nlet element &#061; document.getElementById(&#039;article&#039;);<br \/>\nrange.selectNodeContents(element);<br \/>\nlet content &#061; range.toString();\n<\/li>\n<\/ul>\n<h3>31\u3001document.caretPositionFromPoint()<\/h3>\n<ul>\n<li>\n<p>\u542b\u4e49&#xff1a;\u8fd4\u56de\u6307\u5b9a\u5750\u6807\u5904\u7684\u5149\u6807\u4f4d\u7f6e\u4fe1\u606f&#xff08;\u7528\u4e8e\u6587\u672c\u7f16\u8f91&#xff09;\u3002<\/p>\n<\/li>\n<li>\n<p>\u8bcd\u6e90&#xff1a;Caret&#xff08;\u5149\u6807&#xff09;&#043; Position&#xff08;\u4f4d\u7f6e&#xff09;&#043; From&#xff08;\u4ece&#xff09;&#043; Point&#xff08;\u70b9&#xff09;\u3002<\/p>\n<\/li>\n<li>\n<p>\u8bed\u6cd5&#xff1a;let caretPosition &#061; document.caretPositionFromPoint(x, y);<\/p>\n<\/li>\n<li>\n<p>\u53c2\u6570\u53ca\u8bf4\u660e&#xff1a;<\/p>\n<ul>\n<li>\n<p>x&#xff1a;\u76f8\u5bf9\u4e8e\u89c6\u53e3\u7684\u6c34\u5e73\u5750\u6807&#xff08;\u50cf\u7d20&#xff09;\u3002<\/p>\n<\/li>\n<li>\n<p>y&#xff1a;\u76f8\u5bf9\u4e8e\u89c6\u53e3\u7684\u5782\u76f4\u5750\u6807&#xff08;\u50cf\u7d20&#xff09;\u3002<\/p>\n<\/li>\n<li>\n<p>\u8fd4\u56de\u503c&#xff1a;\u4e00\u4e2a\u00a0CaretPosition\u00a0\u5bf9\u8c61&#xff0c;\u5305\u542b\u00a0offsetNode&#xff08;\u8282\u70b9&#xff09;\u548c\u00a0offset&#xff08;\u504f\u79fb\u91cf&#xff09;&#xff0c;\u5982\u679c\u5750\u6807\u5904\u6ca1\u6709\u6587\u672c\u5219\u8fd4\u56de\u00a0null\u3002<\/p>\n<\/li>\n<li>\n<p>\u6ce8\u610f&#xff1a;\u8fd9\u662f\u4e00\u4e2a\u8f83\u65b0\u7684 API&#xff0c;\u73b0\u4ee3\u6d4f\u89c8\u5668\u652f\u6301\u826f\u597d\u3002<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u4f8b\u5b50&#xff1a;<\/p>\n<p>\/\/ \u5728\u53ef\u7f16\u8f91\u533a\u57df\u4e2d\u70b9\u51fb\u65f6\u83b7\u53d6\u5149\u6807\u4f4d\u7f6e<br \/>\nlet editor &#061; document.getElementById(&#039;editor&#039;);<\/p>\n<p>editor.addEventListener(&#039;click&#039;, function(event) {<br \/>\n    let caretPos &#061; document.caretPositionFromPoint(event.clientX, event.clientY);<\/p>\n<p>    if (caretPos) {<br \/>\n        let node &#061; caretPos.offsetNode;<br \/>\n        let offset &#061; caretPos.offset;<\/p>\n<p>        console.log(&#039;\u70b9\u51fb\u7684\u6587\u672c\u8282\u70b9:&#039;, node);<br \/>\n        console.log(&#039;\u5b57\u7b26\u504f\u79fb\u91cf:&#039;, offset);<\/p>\n<p>        \/\/ \u5982\u679c\u662f\u6587\u672c\u8282\u70b9&#xff0c;\u53ef\u4ee5\u83b7\u53d6\u9644\u8fd1\u7684\u6587\u672c<br \/>\n        if (node.nodeType &#061;&#061;&#061; Node.TEXT_NODE) {<br \/>\n            let text &#061; node.textContent;<br \/>\n            let before &#061; text.substring(0, offset);<br \/>\n            let after &#061; text.substring(offset);<br \/>\n            console.log(&#039;\u5149\u6807\u524d:&#039;, before);<br \/>\n            console.log(&#039;\u5149\u6807\u540e:&#039;, after);<br \/>\n        }<br \/>\n    }<br \/>\n});<\/p>\n<p>\/\/ \u5b9e\u73b0\u81ea\u5b9a\u4e49\u7684\u6587\u672c\u63d2\u5165<br \/>\nfunction insertTextAtCursor(text) {<br \/>\n    let selection &#061; document.getSelection();<br \/>\n    if (selection.rangeCount &gt; 0) {<br \/>\n        let range &#061; selection.getRangeAt(0);<br \/>\n        range.deleteContents(); \/\/ \u5220\u9664\u9009\u4e2d\u7684\u5185\u5bb9<br \/>\n        range.insertNode(document.createTextNode(text)); \/\/ \u63d2\u5165\u65b0\u6587\u672c<br \/>\n    }<br \/>\n}<\/p>\n<p>\/\/ \u83b7\u53d6\u9f20\u6807\u4f4d\u7f6e\u6700\u8fd1\u7684\u5355\u8bcd<br \/>\ndocument.addEventListener(&#039;mouseup&#039;, function(event) {<br \/>\n    let caretPos &#061; document.caretPositionFromPoint(event.clientX, event.clientY);<br \/>\n    if (caretPos &amp;&amp; caretPos.offsetNode.nodeType &#061;&#061;&#061; Node.TEXT_NODE) {<br \/>\n        let text &#061; caretPos.offsetNode.textContent;<br \/>\n        let pos &#061; caretPos.offset;<\/p>\n<p>        \/\/ \u7b80\u5355\u5b9e\u73b0&#xff1a;\u627e\u5230\u5149\u6807\u6240\u5728\u7684\u5355\u8bcd<br \/>\n        let words &#061; text.split(\/\\\\s&#043;\/);<br \/>\n        let charCount &#061; 0;<br \/>\n        for (let word of words) {<br \/>\n            if (pos &gt;&#061; charCount &amp;&amp; pos &lt;&#061; charCount &#043; word.length) {<br \/>\n                console.log(&#039;\u70b9\u51fb\u7684\u5355\u8bcd:&#039;, word);<br \/>\n                break;<br \/>\n            }<br \/>\n            charCount &#043;&#061; word.length &#043; 1; \/\/ &#043;1 \u7a7a\u683c<br \/>\n        }<br \/>\n    }<br \/>\n});\n<\/li>\n<\/ul>\n<h3>32\u3001 document.evaluate()<\/h3>\n<ul>\n<li>\n<p>\u542b\u4e49&#xff1a;\u8bc4\u4f30 XPath \u8868\u8fbe\u5f0f&#xff0c;\u8fd4\u56de\u5339\u914d\u7684\u7ed3\u679c\u3002<\/p>\n<\/li>\n<li>\n<p>\u8bcd\u6e90&#xff1a;Evaluate&#xff08;\u8bc4\u4f30&#xff09;\u3002<\/p>\n<\/li>\n<li>\n<p>\u8bed\u6cd5&#xff1a;let xpathResult &#061; document.evaluate(xpathExpression, contextNode, namespaceResolver, resultType, result);<\/p>\n<\/li>\n<li>\n<p>\u53c2\u6570\u53ca\u8bf4\u660e&#xff1a;<\/p>\n<ul>\n<li>\n<p>xpathExpression&#xff1a;XPath \u8868\u8fbe\u5f0f\u5b57\u7b26\u4e32\u3002<\/p>\n<\/li>\n<li>\n<p>contextNode&#xff1a;\u4e0a\u4e0b\u6587\u8282\u70b9&#xff08;\u901a\u5e38\u662f\u00a0document&#xff09;\u3002<\/p>\n<\/li>\n<li>\n<p>namespaceResolver&#xff1a;\u547d\u540d\u7a7a\u95f4\u89e3\u6790\u51fd\u6570&#xff08;\u901a\u5e38\u4e3a\u00a0null&#xff09;\u3002<\/p>\n<\/li>\n<li>\n<p>resultType&#xff1a;\u8fd4\u56de\u7ed3\u679c\u7684\u7c7b\u578b\u3002<\/p>\n<\/li>\n<li>\n<p>result&#xff1a;\u53ef\u91cd\u7528\u7684\u7ed3\u679c\u5bf9\u8c61&#xff08;\u901a\u5e38\u4e3a\u00a0null&#xff09;\u3002<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u4f8b\u5b50&#xff1a;<\/p>\n<p>\/\/ \u67e5\u627e\u6240\u6709 class \u4e3a &#034;item&#034; \u7684 div<br \/>\nlet result &#061; document.evaluate(<br \/>\n    &#039;\/\/div[&#064;class&#061;&#034;item&#034;]&#039;,<br \/>\n    document,<br \/>\n    null,<br \/>\n    XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,<br \/>\n    null<br \/>\n);<\/p>\n<p>for (let i &#061; 0; i &lt; result.snapshotLength; i&#043;&#043;) {<br \/>\n    console.log(result.snapshotItem(i)); \/\/ \u8f93\u51fa\u5339\u914d\u7684\u5143\u7d20<br \/>\n}<\/p>\n<p>\/\/ \u67e5\u627e\u7b2c\u4e00\u4e2a h1 \u6807\u9898<br \/>\nlet h1 &#061; document.evaluate(<br \/>\n    &#039;\/\/h1&#039;,<br \/>\n    document,<br \/>\n    null,<br \/>\n    XPathResult.FIRST_ORDERED_NODE_TYPE,<br \/>\n    null<br \/>\n).singleNodeValue;<\/p>\n<p>console.log(&#039;\u7b2c\u4e00\u4e2ah1:&#039;, h1);\n<\/li>\n<\/ul>\n<hr \/>\n<h2>\u7b2c\u516d\u90e8\u5206&#xff1a;\u521b\u5efa\u65b9\u6cd5&#xff08;6\u4e2a&#xff09;<\/h2>\n<h3>33\u3001document.createAttribute()<\/h3>\n<ul>\n<li>\n<p>\u542b\u4e49&#xff1a;\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u5c5e\u6027\u8282\u70b9&#xff08;\u901a\u5e38\u4e0d\u63a8\u8350\u4f7f\u7528&#xff0c;\u5efa\u8bae\u7528\u00a0setAttribute&#xff09;\u3002<\/p>\n<\/li>\n<li>\n<p>\u8bcd\u6e90&#xff1a;Create&#xff08;\u521b\u5efa&#xff09;&#043; Attribute&#xff08;\u5c5e\u6027&#xff09;\u3002<\/p>\n<\/li>\n<li>\n<p>\u8bed\u6cd5&#xff1a;let attrNode &#061; document.createAttribute(name);<\/p>\n<\/li>\n<li>\n<p>\u53c2\u6570\u53ca\u8bf4\u660e&#xff1a;<\/p>\n<ul>\n<li>\n<p>name&#xff1a;\u5c5e\u6027\u7684\u540d\u79f0\u3002<\/p>\n<\/li>\n<li>\n<p>\u8fd4\u56de\u503c&#xff1a;\u65b0\u521b\u5efa\u7684\u00a0Attr\u00a0\u8282\u70b9&#xff0c;\u5305\u542b\u00a0name\u00a0\u548c\u00a0value\u00a0\u5c5e\u6027\u3002<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u4f8b\u5b50&#xff1a;<\/p>\n<p>\/\/ \u521b\u5efa\u5c5e\u6027\u8282\u70b9<br \/>\nlet classAttr &#061; document.createAttribute(&#039;class&#039;);<br \/>\nclassAttr.value &#061; &#039;highlight bold&#039;;<\/p>\n<p>let dataAttr &#061; document.createAttribute(&#039;data-id&#039;);<br \/>\ndataAttr.value &#061; &#039;12345&#039;;<\/p>\n<p>\/\/ \u5c06\u5c5e\u6027\u5e94\u7528\u5230\u5143\u7d20<br \/>\nlet div &#061; document.getElementById(&#039;myDiv&#039;);<br \/>\ndiv.setAttributeNode(classAttr);<br \/>\ndiv.setAttributeNode(dataAttr);<\/p>\n<p>console.log(div.outerHTML); \/\/ &lt;div class&#061;&#034;highlight bold&#034; data-id&#061;&#034;12345&#034;&gt;&lt;\/div&gt;<\/p>\n<p>\/\/ \u66f4\u7b80\u5355\u7684\u65b9\u5f0f&#xff08;\u63a8\u8350&#xff09;<br \/>\n\/\/ div.setAttribute(&#039;class&#039;, &#039;highlight bold&#039;);<br \/>\n\/\/ div.setAttribute(&#039;data-id&#039;, &#039;12345&#039;);\n<\/li>\n<\/ul>\n<h3>34\u3001document.createComment()<\/h3>\n<ul>\n<li>\n<p>\u542b\u4e49&#xff1a;\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u6ce8\u91ca\u8282\u70b9\u3002<\/p>\n<\/li>\n<li>\n<p>\u8bcd\u6e90&#xff1a;Create&#xff08;\u521b\u5efa&#xff09;&#043; Comment&#xff08;\u6ce8\u91ca&#xff09;\u3002<\/p>\n<\/li>\n<li>\n<p>\u8bed\u6cd5&#xff1a;let commentNode &#061; document.createComment(data);<\/p>\n<\/li>\n<li>\n<p>\u53c2\u6570\u53ca\u8bf4\u660e&#xff1a;<\/p>\n<ul>\n<li>\n<p>data&#xff1a;\u6ce8\u91ca\u7684\u5185\u5bb9\u5b57\u7b26\u4e32\u3002<\/p>\n<\/li>\n<li>\n<p>\u8fd4\u56de\u503c&#xff1a;\u65b0\u521b\u5efa\u7684\u00a0Comment\u00a0\u8282\u70b9\u3002<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u4f8b\u5b50&#xff1a;<\/p>\n<p>\/\/ \u521b\u5efa\u6ce8\u91ca<br \/>\nlet comment1 &#061; document.createComment(&#039;\u8fd9\u662f\u52a8\u6001\u751f\u6210\u7684\u6ce8\u91ca&#039;);<br \/>\nlet comment2 &#061; document.createComment(&#039;\u521b\u5efa\u65f6\u95f4&#xff1a;&#039; &#043; new Date().toLocaleString());<\/p>\n<p>\/\/ \u6dfb\u52a0\u5230\u9875\u9762<br \/>\ndocument.body.appendChild(comment1);<br \/>\ndocument.getElementById(&#039;footer&#039;).appendChild(comment2);<\/p>\n<p>\/\/ \u5728 HTML \u6e90\u7801\u4e2d\u4f1a\u770b\u5230&#xff1a;<br \/>\n\/\/ &lt;!&#8211;\u8fd9\u662f\u52a8\u6001\u751f\u6210\u7684\u6ce8\u91ca&#8211;&gt;<br \/>\n\/\/ &lt;!&#8211;\u521b\u5efa\u65f6\u95f4&#xff1a;2024\/1\/15 14:30:00&#8211;&gt;<\/p>\n<p>\/\/ \u4e5f\u53ef\u4ee5\u7528\u4e8e\u8c03\u8bd5\u6807\u8bb0<br \/>\nfunction addDebugComment(element, message) {<br \/>\n    let comment &#061; document.createComment(&#096;DEBUG: ${message}&#096;);<br \/>\n    element.parentNode.insertBefore(comment, element);<br \/>\n}\n<\/li>\n<\/ul>\n<h3>35\u3001document.createDocumentFragment()<\/h3>\n<ul>\n<li>\n<p>\u542b\u4e49&#xff1a;\u521b\u5efa\u4e00\u4e2a\u7a7a\u7684\u6587\u6863\u7247\u6bb5&#xff08;\u8f7b\u91cf\u7ea7\u7684\u6587\u6863\u5bb9\u5668&#xff0c;\u7528\u4e8e\u6279\u91cf\u64cd\u4f5c&#xff09;\u3002<\/p>\n<\/li>\n<li>\n<p>\u8bcd\u6e90&#xff1a;Create&#xff08;\u521b\u5efa&#xff09;&#043; Document&#xff08;\u6587\u6863&#xff09;&#043; Fragment&#xff08;\u7247\u6bb5&#xff09;\u3002<\/p>\n<\/li>\n<li>\n<p>\u8bed\u6cd5&#xff1a;let fragment &#061; document.createDocumentFragment();<\/p>\n<\/li>\n<li>\n<p>\u53c2\u6570\u53ca\u8bf4\u660e&#xff1a;\u65e0\u53c2\u6570\u3002\u8fd4\u56de\u4e00\u4e2a\u7a7a\u7684\u00a0DocumentFragment\u00a0\u5bf9\u8c61\u3002<\/p>\n<\/li>\n<li>\n<p>\u4f8b\u5b50&#xff1a;<\/p>\n<p>\/\/ \u521b\u5efa\u7247\u6bb5<br \/>\nlet fragment &#061; document.createDocumentFragment();<\/p>\n<p>\/\/ \u6279\u91cf\u521b\u5efa\u5143\u7d20&#xff08;\u53ea\u89e6\u53d1\u4e00\u6b21\u91cd\u7ed8&#xff09;<br \/>\nfor (let i &#061; 0; i &lt; 1000; i&#043;&#043;) {<br \/>\n    let li &#061; document.createElement(&#039;li&#039;);<br \/>\n    li.textContent &#061; &#096;\u5217\u8868\u9879 ${i &#043; 1}&#096;;<br \/>\n    li.className &#061; i % 2 &#061;&#061;&#061; 0 ? &#039;even&#039; : &#039;odd&#039;;<br \/>\n    fragment.appendChild(li); \/\/ \u5148\u6dfb\u52a0\u5230\u7247\u6bb5&#xff0c;\u4e0d\u4f1a\u89e6\u53d1\u91cd\u7ed8<br \/>\n}<\/p>\n<p>\/\/ \u4e00\u6b21\u6027\u6dfb\u52a0\u5230 DOM&#xff08;\u53ea\u89e6\u53d1\u4e00\u6b21\u91cd\u7ed8&#xff09;<br \/>\nlet list &#061; document.getElementById(&#039;big-list&#039;);<br \/>\nlist.appendChild(fragment);<\/p>\n<p>console.log(&#039;1000 \u4e2a\u9879\u76ee\u5df2\u9ad8\u6548\u6dfb\u52a0&#039;);<\/p>\n<p>\/\/ \u53e6\u4e00\u4e2a\u4f8b\u5b50&#xff1a;\u6784\u5efa\u590d\u6742\u7ed3\u6784<br \/>\nfunction buildCard(title, content) {<br \/>\n    let fragment &#061; document.createDocumentFragment();<\/p>\n<p>    let header &#061; document.createElement(&#039;h3&#039;);<br \/>\n    header.textContent &#061; title;<\/p>\n<p>    let body &#061; document.createElement(&#039;p&#039;);<br \/>\n    body.textContent &#061; content;<\/p>\n<p>    let footer &#061; document.createElement(&#039;div&#039;);<br \/>\n    footer.className &#061; &#039;card-footer&#039;;<\/p>\n<p>    fragment.appendChild(header);<br \/>\n    fragment.appendChild(body);<br \/>\n    fragment.appendChild(footer);<\/p>\n<p>    return fragment;<br \/>\n}\n<\/li>\n<\/ul>\n<h3>36\u3001document.createEvent()<\/h3>\n<ul>\n<li>\n<p>\u542b\u4e49&#xff1a;\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u4e8b\u4ef6\u5bf9\u8c61&#xff08;\u65e7\u5f0f\u65b9\u6cd5&#xff0c;\u63a8\u8350\u4f7f\u7528\u00a0new Event()\u00a0\u6784\u9020\u51fd\u6570&#xff09;\u3002<\/p>\n<\/li>\n<li>\n<p>\u8bcd\u6e90&#xff1a;Create&#xff08;\u521b\u5efa&#xff09;&#043; Event&#xff08;\u4e8b\u4ef6&#xff09;\u3002<\/p>\n<\/li>\n<li>\n<p>\u8bed\u6cd5&#xff1a;let event &#061; document.createEvent(type);<\/p>\n<\/li>\n<li>\n<p>\u53c2\u6570\u53ca\u8bf4\u660e&#xff1a;<\/p>\n<ul>\n<li>\n<p>type&#xff1a;\u4e8b\u4ef6\u7c7b\u578b\u5b57\u7b26\u4e32&#xff0c;\u5982&#xff1a;<\/p>\n<ul>\n<li>\n<p>&#039;MouseEvents&#039;&#xff1a;\u9f20\u6807\u4e8b\u4ef6<\/p>\n<\/li>\n<li>\n<p>&#039;HTMLEvents&#039;&#xff1a;HTML \u4e8b\u4ef6<\/p>\n<\/li>\n<li>\n<p>&#039;UIEvents&#039;&#xff1a;UI \u4e8b\u4ef6<\/p>\n<\/li>\n<li>\n<p>&#039;KeyboardEvents&#039;&#xff1a;\u952e\u76d8\u4e8b\u4ef6<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u8fd4\u56de\u503c&#xff1a;\u521b\u5efa\u7684\u4e8b\u4ef6\u5bf9\u8c61&#xff0c;\u9700\u8981\u8fdb\u4e00\u6b65\u521d\u59cb\u5316\u3002<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u4f8b\u5b50&#xff1a;<\/p>\n<p>\/\/ \u65e7\u5f0f\u65b9\u6cd5&#xff08;\u4e0d\u63a8\u8350&#xff0c;\u4ec5\u4e3a\u4e86\u89e3&#xff09;<\/p>\n<p>\/\/ \u521b\u5efa\u9f20\u6807\u4e8b\u4ef6<br \/>\nlet clickEvent &#061; document.createEvent(&#039;MouseEvents&#039;);<br \/>\nclickEvent.initMouseEvent(<br \/>\n    &#039;click&#039;,        \/\/ \u4e8b\u4ef6\u7c7b\u578b<br \/>\n    true,           \/\/ \u662f\u5426\u5192\u6ce1<br \/>\n    true,           \/\/ \u662f\u5426\u53ef\u53d6\u6d88<br \/>\n    window,         \/\/ \u89c6\u56fe<br \/>\n    0,              \/\/ \u70b9\u51fb\u6b21\u6570<br \/>\n    100, 100,       \/\/ \u5c4f\u5e55\u5750\u6807<br \/>\n    50, 50,         \/\/ \u5ba2\u6237\u533a\u5750\u6807<br \/>\n    false, false, false, false, \/\/ Ctrl, Alt, Shift, Meta<br \/>\n    0,              \/\/ \u9f20\u6807\u6309\u94ae&#xff08;0&#061;\u5de6\u952e&#xff09;<br \/>\n    null            \/\/ \u76f8\u5173\u76ee\u6807<br \/>\n);<\/p>\n<p>\/\/ \u6d3e\u53d1\u4e8b\u4ef6<br \/>\nlet button &#061; document.getElementById(&#039;myButton&#039;);<br \/>\nbutton.dispatchEvent(clickEvent);<\/p>\n<p>\/\/ \u73b0\u4ee3\u63a8\u8350\u5199\u6cd5<br \/>\n\/\/ let clickEvent &#061; new MouseEvent(&#039;click&#039;, {<br \/>\n\/\/     bubbles: true,<br \/>\n\/\/     clientX: 50,<br \/>\n\/\/     clientY: 50<br \/>\n\/\/ });\n<\/li>\n<\/ul>\n<h3>37\u3001document.createElement()<\/h3>\n<ul>\n<li>\n<p>\u542b\u4e49&#xff1a;\u521b\u5efa\u4e00\u4e2a\u65b0\u7684 HTML \u5143\u7d20\u8282\u70b9\u3002<\/p>\n<\/li>\n<li>\n<p>\u8bcd\u6e90&#xff1a;Create&#xff08;\u521b\u5efa&#xff09;&#043; Element&#xff08;\u5143\u7d20&#xff09;\u3002<\/p>\n<\/li>\n<li>\n<p>\u8bed\u6cd5&#xff1a;let element &#061; document.createElement(tagName, options);<\/p>\n<\/li>\n<li>\n<p>\u53c2\u6570\u53ca\u8bf4\u660e&#xff1a;<\/p>\n<ul>\n<li>\n<p>tagName&#xff1a;\u8981\u521b\u5efa\u7684\u5143\u7d20\u7684\u6807\u7b7e\u540d&#xff08;\u5982\u00a0&#039;div&#039;\u3001&#039;span&#039;\u3001&#039;custom-element&#039;&#xff09;\u3002<\/p>\n<\/li>\n<li>\n<p>options&#xff08;\u53ef\u9009&#xff09;&#xff1a;\u4e00\u4e2a\u5bf9\u8c61&#xff0c;\u53ef\u4ee5\u5305\u542b\u00a0is\u00a0\u5c5e\u6027\u6765\u6307\u5b9a\u81ea\u5b9a\u4e49\u5143\u7d20\u3002<\/p>\n<\/li>\n<li>\n<p>\u8fd4\u56de\u503c&#xff1a;\u65b0\u521b\u5efa\u7684\u00a0Element\u00a0\u5bf9\u8c61\u3002<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u4f8b\u5b50&#xff1a;<\/p>\n<p>\/\/ \u57fa\u672c\u7528\u6cd5<br \/>\nlet div &#061; document.createElement(&#039;div&#039;);<br \/>\ndiv.id &#061; &#039;new-div&#039;;<br \/>\ndiv.className &#061; &#039;box&#039;;<br \/>\ndiv.textContent &#061; &#039;\u6211\u662f\u65b0\u521b\u5efa\u7684 Div&#039;;<\/p>\n<p>\/\/ \u8bbe\u7f6e\u6837\u5f0f<br \/>\ndiv.style.padding &#061; &#039;10px&#039;;<br \/>\ndiv.style.backgroundColor &#061; &#039;lightblue&#039;;<\/p>\n<p>\/\/ \u521b\u5efa\u81ea\u5b9a\u4e49\u5143\u7d20&#xff08;\u5982\u679c\u5df2\u6ce8\u518c&#xff09;<br \/>\n\/\/ let myElement &#061; document.createElement(&#039;custom-element&#039;, { is: &#039;my-button&#039; });<\/p>\n<p>\/\/ \u6dfb\u52a0\u5230\u9875\u9762<br \/>\ndocument.body.appendChild(div);<\/p>\n<p>\/\/ \u521b\u5efa\u5e26\u547d\u540d\u7a7a\u95f4\u7684\u5143\u7d20&#xff08;\u5982 SVG&#xff09;<br \/>\nlet svg &#061; document.createElementNS(&#039;http:\/\/www.w3.org\/2000\/svg&#039;, &#039;svg&#039;);<br \/>\nlet circle &#061; document.createElementNS(&#039;http:\/\/www.w3.org\/2000\/svg&#039;, &#039;circle&#039;);<br \/>\nsvg.appendChild(circle);\n<\/li>\n<\/ul>\n<h3>38\u3001document.createTextNode()<\/h3>\n<ul>\n<li>\n<p>\u542b\u4e49&#xff1a;\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u6587\u672c\u8282\u70b9\u3002<\/p>\n<\/li>\n<li>\n<p>\u8bcd\u6e90&#xff1a;Create&#xff08;\u521b\u5efa&#xff09;&#043; Text&#xff08;\u6587\u672c&#xff09;&#043; Node&#xff08;\u8282\u70b9&#xff09;\u3002<\/p>\n<\/li>\n<li>\n<p>\u8bed\u6cd5&#xff1a;let textNode &#061; document.createTextNode(data);<\/p>\n<\/li>\n<li>\n<p>\u53c2\u6570\u53ca\u8bf4\u660e&#xff1a;<\/p>\n<ul>\n<li>\n<p>data&#xff1a;\u4e00\u4e2a\u5b57\u7b26\u4e32&#xff0c;\u662f\u8981\u653e\u5165\u6587\u672c\u8282\u70b9\u7684\u5185\u5bb9\u3002<\/p>\n<\/li>\n<li>\n<p>\u8fd4\u56de\u503c&#xff1a;\u65b0\u521b\u5efa\u7684\u00a0Text\u00a0\u8282\u70b9\u3002<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u4f8b\u5b50&#xff1a;<\/p>\n<p>\/\/ \u521b\u5efa\u6587\u672c\u8282\u70b9<br \/>\nlet text1 &#061; document.createTextNode(&#039;\u8fd9\u662f\u4e00\u6bb5\u666e\u901a\u6587\u672c&#039;);<br \/>\nlet text2 &#061; document.createTextNode(&#039;\u53e6\u4e00\u6bb5\u6587\u672c&#039;);<\/p>\n<p>\/\/ \u521b\u5efa\u5143\u7d20\u5e76\u6dfb\u52a0\u6587\u672c<br \/>\nlet paragraph &#061; document.createElement(&#039;p&#039;);<br \/>\nparagraph.appendChild(text1);<\/p>\n<p>\/\/ \u5728\u6587\u672c\u540e\u8ffd\u52a0\u66f4\u591a\u6587\u672c<br \/>\nparagraph.appendChild(document.createTextNode(&#039; &#8211; \u8ffd\u52a0\u7684\u5185\u5bb9&#039;));<\/p>\n<p>\/\/ \u4fee\u6539\u6587\u672c\u5185\u5bb9<br \/>\ntext1.nodeValue &#061; &#039;\u4fee\u6539\u540e\u7684\u6587\u672c&#039;;<\/p>\n<p>\/\/ \u6ce8\u610f&#xff1a;createTextNode \u4f1a\u8f6c\u4e49 HTML \u6807\u7b7e<br \/>\nlet safeText &#061; document.createTextNode(&#039;&lt;script&gt;alert(&#034;xss&#034;)&lt;\/script&gt;&#039;);<br \/>\n\/\/ \u9875\u9762\u4f1a\u663e\u793a\u539f\u6587&#xff0c;\u4e0d\u4f1a\u6267\u884c\u811a\u672c<br \/>\ndocument.body.appendChild(safeText);\n<\/li>\n<\/ul>\n<hr \/>\n<h2>\u7b2c\u4e03\u90e8\u5206&#xff1a;\u6bd4\u8f83\u4e0e\u547d\u540d\u7a7a\u95f4\u65b9\u6cd5&#xff08;7\u4e2a&#xff09;<\/h2>\n<h3>39\u3001document.compareDocumentPosition()<\/h3>\n<ul>\n<li>\n<p>\u542b\u4e49&#xff1a;\u6bd4\u8f83\u5f53\u524d\u6587\u6863\u548c\u53e6\u4e00\u4e2a\u8282\u70b9\u7684\u4f4d\u7f6e\u5173\u7cfb\u3002<\/p>\n<\/li>\n<li>\n<p>\u8bcd\u6e90&#xff1a;Compare&#xff08;\u6bd4\u8f83&#xff09;&#043; Document&#xff08;\u6587\u6863&#xff09;&#043; Position&#xff08;\u4f4d\u7f6e&#xff09;\u3002<\/p>\n<\/li>\n<li>\n<p>\u8bed\u6cd5&#xff1a;let relationship &#061; document.compareDocumentPosition(otherNode);<\/p>\n<\/li>\n<li>\n<p>\u53c2\u6570\u53ca\u8bf4\u660e&#xff1a;<\/p>\n<ul>\n<li>\n<p>otherNode&#xff1a;\u8981\u6bd4\u8f83\u7684\u53e6\u4e00\u4e2a\u8282\u70b9\u3002<\/p>\n<\/li>\n<li>\n<p>\u8fd4\u56de\u503c&#xff1a;\u4e00\u4e2a\u4f4d\u63a9\u7801&#xff08;\u6574\u6570&#xff09;&#xff0c;\u8868\u793a\u4e24\u4e2a\u8282\u70b9\u7684\u5173\u7cfb\u3002\u53ef\u80fd\u7684\u503c&#xff1a;<\/p>\n<ul>\n<li>\n<p>0&#xff1a;\u4e24\u4e2a\u8282\u70b9\u76f8\u540c<\/p>\n<\/li>\n<li>\n<p>1&#xff1a;\u8282\u70b9\u4e0d\u5728\u540c\u4e00\u6587\u6863\u4e2d<\/p>\n<\/li>\n<li>\n<p>2&#xff1a;otherNode \u5728\u5f53\u524d\u8282\u70b9\u4e4b\u524d<\/p>\n<\/li>\n<li>\n<p>4&#xff1a;otherNode \u5728\u5f53\u524d\u8282\u70b9\u4e4b\u540e<\/p>\n<\/li>\n<li>\n<p>8&#xff1a;otherNode \u5305\u542b\u5f53\u524d\u8282\u70b9<\/p>\n<\/li>\n<li>\n<p>16&#xff1a;otherNode \u88ab\u5f53\u524d\u8282\u70b9\u5305\u542b<\/p>\n<\/li>\n<li>\n<p>32&#xff1a;\u6d4f\u89c8\u5668\u7684\u79c1\u6709\u4f7f\u7528<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u4f8b\u5b50&#xff1a;<\/p>\n<p>let head &#061; document.head;<br \/>\nlet body &#061; document.body;<\/p>\n<p>\/\/ \u6bd4\u8f83 head \u548c body \u7684\u4f4d\u7f6e<br \/>\nlet result &#061; head.compareDocumentPosition(body);<\/p>\n<p>\/\/ \u4f7f\u7528\u4f4d\u8fd0\u7b97\u68c0\u67e5\u5173\u7cfb<br \/>\nif (result &amp; Node.DOCUMENT_POSITION_FOLLOWING) {<br \/>\n    console.log(&#039;head \u5728 body \u4e4b\u524d&#039;); \/\/ \u901a\u5e38\u4f1a\u8f93\u51fa\u8fd9\u4e2a<br \/>\n}<\/p>\n<p>if (result &amp; Node.DOCUMENT_POSITION_PRECEDING) {<br \/>\n    console.log(&#039;head \u5728 body \u4e4b\u540e&#039;);<br \/>\n}<\/p>\n<p>\/\/ \u68c0\u67e5\u5143\u7d20\u662f\u5426\u5305\u542b\u53e6\u4e00\u4e2a\u5143\u7d20<br \/>\nlet parent &#061; document.getElementById(&#039;parent&#039;);<br \/>\nlet child &#061; document.getElementById(&#039;child&#039;);<\/p>\n<p>if (parent.compareDocumentPosition(child) &amp; Node.DOCUMENT_POSITION_CONTAINED_BY) {<br \/>\n    console.log(&#039;child \u88ab parent \u5305\u542b&#039;);<br \/>\n}<\/p>\n<p>\/\/ \u5e38\u91cf\u5b9a\u4e49&#xff08;\u4fbf\u4e8e\u9605\u8bfb&#xff09;<br \/>\nconst POSITION &#061; {<br \/>\n    DISCONNECTED: 1,<br \/>\n    PRECEDING: 2,<br \/>\n    FOLLOWING: 4,<br \/>\n    CONTAINS: 8,<br \/>\n    CONTAINED_BY: 16<br \/>\n};\n<\/li>\n<\/ul>\n<h3>40\u3001document.contains()<\/h3>\n<ul>\n<li>\n<p>\u542b\u4e49&#xff1a;\u68c0\u67e5\u4e00\u4e2a\u8282\u70b9\u662f\u5426\u662f\u6587\u6863\u7684\u540e\u4ee3\u8282\u70b9\u3002<\/p>\n<\/li>\n<li>\n<p>\u8bcd\u6e90&#xff1a;Contains&#xff08;\u5305\u542b&#xff09;\u3002<\/p>\n<\/li>\n<li>\n<p>\u8bed\u6cd5&#xff1a;let isDescendant &#061; document.contains(otherNode);<\/p>\n<\/li>\n<li>\n<p>\u53c2\u6570\u53ca\u8bf4\u660e&#xff1a;<\/p>\n<ul>\n<li>\n<p>otherNode&#xff1a;\u8981\u68c0\u67e5\u7684\u8282\u70b9\u3002<\/p>\n<\/li>\n<li>\n<p>\u8fd4\u56de\u503c&#xff1a;\u5e03\u5c14\u503c&#xff0c;\u5982\u679c\u8282\u70b9\u662f\u6587\u6863\u7684\u4e00\u90e8\u5206\u8fd4\u56de\u00a0true&#xff0c;\u5426\u5219\u8fd4\u56de\u00a0false\u3002<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u4f8b\u5b50&#xff1a;<\/p>\n<p>let div &#061; document.getElementById(&#039;myDiv&#039;);<br \/>\nconsole.log(document.contains(div)); \/\/ true&#xff08;div \u5728\u9875\u9762\u4e2d&#xff09;<\/p>\n<p>\/\/ \u68c0\u67e5\u65b0\u521b\u5efa\u7684\u8282\u70b9<br \/>\nlet newDiv &#061; document.createElement(&#039;div&#039;);<br \/>\nconsole.log(document.contains(newDiv)); \/\/ false&#xff08;\u8fd8\u6ca1\u6dfb\u52a0\u5230\u9875\u9762&#xff09;<\/p>\n<p>\/\/ \u6dfb\u52a0\u5230\u9875\u9762\u540e<br \/>\ndocument.body.appendChild(newDiv);<br \/>\nconsole.log(document.contains(newDiv)); \/\/ true<\/p>\n<p>\/\/ \u68c0\u67e5 null \u6216 undefined<br \/>\nconsole.log(document.contains(null)); \/\/ false<\/p>\n<p>\/\/ \u68c0\u67e5\u6587\u6863\u81ea\u8eab<br \/>\nconsole.log(document.contains(document)); \/\/ true<\/p>\n<p>\/\/ \u5b9e\u7528\u573a\u666f&#xff1a;\u68c0\u67e5\u5143\u7d20\u662f\u5426\u8fd8\u5728 DOM \u4e2d<br \/>\nfunction isInDOM(element) {<br \/>\n    return document.contains(element);<br \/>\n}<\/p>\n<p>\/\/ \u5b9a\u671f\u68c0\u67e5\u5143\u7d20\u662f\u5426\u5b58\u5728<br \/>\nlet element &#061; document.getElementById(&#039;temp&#039;);<br \/>\nsetInterval(() &#061;&gt; {<br \/>\n    if (!document.contains(element)) {<br \/>\n        console.log(&#039;\u5143\u7d20\u5df2\u88ab\u79fb\u9664&#039;);<br \/>\n        element &#061; null;<br \/>\n    }<br \/>\n}, 1000);\n<\/li>\n<\/ul>\n<h3>41\u3001document.isDefaultNamespace()<\/h3>\n<ul>\n<li>\n<p>\u542b\u4e49&#xff1a;\u68c0\u67e5\u6307\u5b9a\u7684\u547d\u540d\u7a7a\u95f4 URI \u662f\u5426\u4e3a\u6587\u6863\u7684\u9ed8\u8ba4\u547d\u540d\u7a7a\u95f4\u3002<\/p>\n<\/li>\n<li>\n<p>\u8bcd\u6e90&#xff1a;Is&#xff08;\u662f&#xff09;&#043; Default&#xff08;\u9ed8\u8ba4&#xff09;&#043; Namespace&#xff08;\u547d\u540d\u7a7a\u95f4&#xff09;\u3002<\/p>\n<\/li>\n<li>\n<p>\u8bed\u6cd5&#xff1a;let bool &#061; document.isDefaultNamespace(namespaceURI);<\/p>\n<\/li>\n<li>\n<p>\u53c2\u6570\u53ca\u8bf4\u660e&#xff1a;<\/p>\n<ul>\n<li>\n<p>namespaceURI&#xff1a;\u8981\u68c0\u67e5\u7684\u547d\u540d\u7a7a\u95f4 URI \u5b57\u7b26\u4e32\u3002<\/p>\n<\/li>\n<li>\n<p>\u8fd4\u56de\u503c&#xff1a;\u5e03\u5c14\u503c&#xff0c;\u5982\u679c\u662f\u9ed8\u8ba4\u547d\u540d\u7a7a\u95f4\u8fd4\u56de\u00a0true&#xff0c;\u5426\u5219\u8fd4\u56de\u00a0false\u3002<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u4f8b\u5b50&#xff1a;<\/p>\n<p>\/\/ \u68c0\u67e5 HTML \u547d\u540d\u7a7a\u95f4<br \/>\nlet isHTML &#061; document.isDefaultNamespace(&#039;http:\/\/www.w3.org\/1999\/xhtml&#039;);<br \/>\nconsole.log(&#039;\u662f HTML \u9ed8\u8ba4\u547d\u540d\u7a7a\u95f4&#xff1f;&#039;, isHTML); \/\/ true<\/p>\n<p>\/\/ \u68c0\u67e5 SVG \u547d\u540d\u7a7a\u95f4<br \/>\nlet isSVG &#061; document.isDefaultNamespace(&#039;http:\/\/www.w3.org\/2000\/svg&#039;);<br \/>\nconsole.log(&#039;\u662f SVG \u9ed8\u8ba4\u547d\u540d\u7a7a\u95f4&#xff1f;&#039;, isSVG); \/\/ false<\/p>\n<p>\/\/ \u5728 XML \u6587\u6863\u4e2d\u4f7f\u7528<br \/>\nif (document.isDefaultNamespace(&#039;http:\/\/www.w3.org\/1999\/xhtml&#039;)) {<br \/>\n    console.log(&#039;\u5f53\u524d\u662f HTML \u6587\u6863&#039;);<br \/>\n}\n<\/li>\n<\/ul>\n<h3>42\u3001document.isEqualNode()<\/h3>\n<ul>\n<li>\n<p>\u542b\u4e49&#xff1a;\u68c0\u67e5\u4e24\u4e2a\u8282\u70b9\u662f\u5426\u76f8\u7b49&#xff08;\u5177\u6709\u76f8\u540c\u7684\u7c7b\u578b\u3001\u5c5e\u6027\u3001\u5b50\u8282\u70b9\u7b49&#xff0c;\u4f46\u4e0d\u4e00\u5b9a\u662f\u540c\u4e00\u4e2a\u5f15\u7528&#xff09;\u3002<\/p>\n<\/li>\n<li>\n<p>\u8bcd\u6e90&#xff1a;Is&#xff08;\u662f&#xff09;&#043; Equal&#xff08;\u76f8\u7b49&#xff09;&#043; Node&#xff08;\u8282\u70b9&#xff09;\u3002<\/p>\n<\/li>\n<li>\n<p>\u8bed\u6cd5&#xff1a;let isEqual &#061; document.isEqualNode(otherNode);<\/p>\n<\/li>\n<li>\n<p>\u53c2\u6570\u53ca\u8bf4\u660e&#xff1a;<\/p>\n<ul>\n<li>\n<p>otherNode&#xff1a;\u8981\u6bd4\u8f83\u7684\u53e6\u4e00\u4e2a\u8282\u70b9\u3002<\/p>\n<\/li>\n<li>\n<p>\u8fd4\u56de\u503c&#xff1a;\u5e03\u5c14\u503c&#xff0c;\u5982\u679c\u4e24\u4e2a\u8282\u70b9\u5b8c\u5168\u76f8\u7b49\u8fd4\u56de\u00a0true\u3002<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u4f8b\u5b50&#xff1a;<\/p>\n<p>\/\/ \u521b\u5efa\u4e24\u4e2a\u7ed3\u6784\u76f8\u540c\u7684\u5143\u7d20<br \/>\nlet div1 &#061; document.createElement(&#039;div&#039;);<br \/>\ndiv1.id &#061; &#039;test&#039;;<br \/>\ndiv1.className &#061; &#039;box&#039;;<br \/>\ndiv1.textContent &#061; &#039;\u5185\u5bb9&#039;;<\/p>\n<p>let div2 &#061; document.createElement(&#039;div&#039;);<br \/>\ndiv2.id &#061; &#039;test&#039;;<br \/>\ndiv2.className &#061; &#039;box&#039;;<br \/>\ndiv2.textContent &#061; &#039;\u5185\u5bb9&#039;;<\/p>\n<p>\/\/ \u68c0\u67e5\u662f\u5426\u76f8\u7b49&#xff08;\u7ed3\u6784\u76f8\u540c&#xff09;<br \/>\nconsole.log(div1.isEqualNode(div2)); \/\/ true<\/p>\n<p>\/\/ \u68c0\u67e5\u662f\u5426\u662f\u540c\u4e00\u4e2a\u8282\u70b9&#xff08;\u5f15\u7528\u76f8\u540c&#xff09;<br \/>\nconsole.log(div1 &#061;&#061;&#061; div2); \/\/ false<\/p>\n<p>\/\/ \u7a0d\u5fae\u4fee\u6539\u4e00\u70b9<br \/>\ndiv2.textContent &#061; &#039;\u4e0d\u540c\u5185\u5bb9&#039;;<br \/>\nconsole.log(div1.isEqualNode(div2)); \/\/ false<\/p>\n<p>\/\/ \u6bd4\u8f83\u6587\u6863\u7247\u6bb5<br \/>\nlet frag1 &#061; document.createDocumentFragment();<br \/>\nlet frag2 &#061; document.createDocumentFragment();<br \/>\nconsole.log(frag1.isEqualNode(frag2)); \/\/ true&#xff08;\u90fd\u662f\u7a7a\u7247\u6bb5&#xff09;<\/p>\n<p>\/\/ \u5b9e\u7528\u573a\u666f&#xff1a;\u68c0\u67e5\u4e24\u4e2a\u5143\u7d20\u662f\u5426\u76f8\u540c&#xff08;\u4e0d\u8003\u8651\u5f15\u7528&#xff09;<br \/>\nfunction areElementsIdentical(el1, el2) {<br \/>\n    return el1.isEqualNode(el2);<br \/>\n}\n<\/li>\n<\/ul>\n<h3>43\u3001document.isSameNode()<\/h3>\n<ul>\n<li>\n<p>\u542b\u4e49&#xff1a;\u68c0\u67e5\u4e24\u4e2a\u8282\u70b9\u662f\u5426\u662f\u540c\u4e00\u4e2a\u8282\u70b9&#xff08;\u5f15\u7528\u76f8\u540c&#xff09;\u3002<\/p>\n<\/li>\n<li>\n<p>\u8bcd\u6e90&#xff1a;Is&#xff08;\u662f&#xff09;&#043; Same&#xff08;\u76f8\u540c&#xff09;&#043; Node&#xff08;\u8282\u70b9&#xff09;\u3002<\/p>\n<\/li>\n<li>\n<p>\u8bed\u6cd5&#xff1a;let isSame &#061; document.isSameNode(otherNode);<\/p>\n<\/li>\n<li>\n<p>\u53c2\u6570\u53ca\u8bf4\u660e&#xff1a;<\/p>\n<ul>\n<li>\n<p>otherNode&#xff1a;\u8981\u6bd4\u8f83\u7684\u53e6\u4e00\u4e2a\u8282\u70b9\u3002<\/p>\n<\/li>\n<li>\n<p>\u8fd4\u56de\u503c&#xff1a;\u5e03\u5c14\u503c&#xff0c;\u5982\u679c\u4e24\u4e2a\u8282\u70b9\u662f\u540c\u4e00\u4e2a\u5bf9\u8c61\u8fd4\u56de\u00a0true\u3002<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u4f8b\u5b50&#xff1a;<\/p>\n<p>let div1 &#061; document.getElementById(&#039;myDiv&#039;);<br \/>\nlet div2 &#061; document.getElementById(&#039;myDiv&#039;);<\/p>\n<p>\/\/ \u68c0\u67e5\u662f\u5426\u662f\u540c\u4e00\u4e2a\u8282\u70b9<br \/>\nconsole.log(div1.isSameNode(div2)); \/\/ true<\/p>\n<p>\/\/ \u7b49\u4ef7\u4e8e<br \/>\nconsole.log(div1 &#061;&#061;&#061; div2); \/\/ true<\/p>\n<p>\/\/ \u590d\u5236\u540e\u7684\u8282\u70b9\u4e0d\u662f\u540c\u4e00\u4e2a<br \/>\nlet div3 &#061; div1.cloneNode(true);<br \/>\nconsole.log(div1.isSameNode(div3)); \/\/ false<\/p>\n<p>\/\/ \u5b9e\u7528\u573a\u666f&#xff1a;\u907f\u514d\u91cd\u590d\u5904\u7406<br \/>\nfunction processElement(element) {<br \/>\n    if (processedElement &amp;&amp; processedElement.isSameNode(element)) {<br \/>\n        console.log(&#039;\u5df2\u7ecf\u5904\u7406\u8fc7\u8fd9\u4e2a\u5143\u7d20\u4e86&#039;);<br \/>\n        return;<br \/>\n    }<br \/>\n    \/\/ \u5904\u7406\u5143\u7d20<br \/>\n    processedElement &#061; element;<br \/>\n}\n<\/li>\n<\/ul>\n<h3>44\u3001document.lookupNamespaceURI()<\/h3>\n<ul>\n<li>\n<p>\u542b\u4e49&#xff1a;\u8fd4\u56de\u7ed9\u5b9a\u524d\u7f00\u5bf9\u5e94\u7684\u547d\u540d\u7a7a\u95f4 URI\u3002<\/p>\n<\/li>\n<li>\n<p>\u8bcd\u6e90&#xff1a;Lookup&#xff08;\u67e5\u627e&#xff09;&#043; Namespace&#xff08;\u547d\u540d\u7a7a\u95f4&#xff09;&#043; URI\u3002<\/p>\n<\/li>\n<li>\n<p>\u8bed\u6cd5&#xff1a;let namespaceURI &#061; document.lookupNamespaceURI(prefix);<\/p>\n<\/li>\n<li>\n<p>\u53c2\u6570\u53ca\u8bf4\u660e&#xff1a;<\/p>\n<ul>\n<li>\n<p>prefix&#xff1a;\u8981\u67e5\u627e\u7684\u524d\u7f00\u5b57\u7b26\u4e32&#xff08;\u5982\u00a0&#039;svg&#039;\u3001&#039;xhtml&#039;&#xff09;\u3002\u4f20\u5165\u00a0null\u00a0\u8fd4\u56de\u9ed8\u8ba4\u547d\u540d\u7a7a\u95f4\u3002<\/p>\n<\/li>\n<li>\n<p>\u8fd4\u56de\u503c&#xff1a;\u5bf9\u5e94\u7684\u547d\u540d\u7a7a\u95f4 URI \u5b57\u7b26\u4e32&#xff0c;\u5982\u679c\u6ca1\u6709\u5219\u8fd4\u56de\u00a0null\u3002<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u4f8b\u5b50&#xff1a;<\/p>\n<p>\/\/ \u67e5\u627e\u9ed8\u8ba4\u547d\u540d\u7a7a\u95f4<br \/>\nlet defaultNS &#061; document.lookupNamespaceURI(null);<br \/>\nconsole.log(&#039;\u9ed8\u8ba4\u547d\u540d\u7a7a\u95f4&#xff1a;&#039;, defaultNS); \/\/ &#039;http:\/\/www.w3.org\/1999\/xhtml&#039;<\/p>\n<p>\/\/ \u67e5\u627e\u7279\u5b9a\u524d\u7f00\u7684\u547d\u540d\u7a7a\u95f4<br \/>\nlet svgNS &#061; document.lookupNamespaceURI(&#039;svg&#039;);<br \/>\nconsole.log(&#039;SVG \u547d\u540d\u7a7a\u95f4&#xff1a;&#039;, svgNS); \/\/ &#039;http:\/\/www.w3.org\/2000\/svg&#039;<\/p>\n<p>let xlinkNS &#061; document.lookupNamespaceURI(&#039;xlink&#039;);<br \/>\nconsole.log(&#039;XLink \u547d\u540d\u7a7a\u95f4&#xff1a;&#039;, xlinkNS); \/\/ &#039;http:\/\/www.w3.org\/1999\/xlink&#039;<\/p>\n<p>\/\/ \u5728 XML \u6587\u6863\u4e2d\u4f7f\u7528<br \/>\nfunction getNamespaceInfo() {<br \/>\n    return {<br \/>\n        default: document.lookupNamespaceURI(null),<br \/>\n        html: document.lookupNamespaceURI(&#039;html&#039;),<br \/>\n        svg: document.lookupNamespaceURI(&#039;svg&#039;),<br \/>\n        math: document.lookupNamespaceURI(&#039;math&#039;)<br \/>\n    };<br \/>\n}\n<\/li>\n<\/ul>\n<h3>45\u3001document.lookupPrefix()<\/h3>\n<ul>\n<li>\n<p>\u542b\u4e49&#xff1a;\u8fd4\u56de\u7ed9\u5b9a\u547d\u540d\u7a7a\u95f4 URI \u5bf9\u5e94\u7684\u524d\u7f00\u3002<\/p>\n<\/li>\n<li>\n<p>\u8bcd\u6e90&#xff1a;Lookup&#xff08;\u67e5\u627e&#xff09;&#043; Prefix&#xff08;\u524d\u7f00&#xff09;\u3002<\/p>\n<\/li>\n<li>\n<p>\u8bed\u6cd5&#xff1a;let prefix &#061; document.lookupPrefix(namespaceURI);<\/p>\n<\/li>\n<li>\n<p>\u53c2\u6570\u53ca\u8bf4\u660e&#xff1a;<\/p>\n<ul>\n<li>\n<p>namespaceURI&#xff1a;\u8981\u67e5\u627e\u7684\u547d\u540d\u7a7a\u95f4 URI \u5b57\u7b26\u4e32\u3002<\/p>\n<\/li>\n<li>\n<p>\u8fd4\u56de\u503c&#xff1a;\u5bf9\u5e94\u7684\u524d\u7f00\u5b57\u7b26\u4e32&#xff0c;\u5982\u679c\u6ca1\u6709\u5219\u8fd4\u56de\u00a0null\u3002<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u4f8b\u5b50&#xff1a;<\/p>\n<p>\/\/ \u67e5\u627e HTML \u547d\u540d\u7a7a\u95f4\u7684\u524d\u7f00<br \/>\nlet htmlPrefix &#061; document.lookupPrefix(&#039;http:\/\/www.w3.org\/1999\/xhtml&#039;);<br \/>\nconsole.log(&#039;HTML \u524d\u7f00&#xff1a;&#039;, htmlPrefix); \/\/ null&#xff08;HTML \u662f\u9ed8\u8ba4\u547d\u540d\u7a7a\u95f4&#xff0c;\u65e0\u524d\u7f00&#xff09;<\/p>\n<p>\/\/ \u67e5\u627e SVG \u547d\u540d\u7a7a\u95f4\u7684\u524d\u7f00<br \/>\nlet svgPrefix &#061; document.lookupPrefix(&#039;http:\/\/www.w3.org\/2000\/svg&#039;);<br \/>\nconsole.log(&#039;SVG \u524d\u7f00&#xff1a;&#039;, svgPrefix); \/\/ &#039;svg&#039;&#xff08;\u5982\u679c\u6709\u5b9a\u4e49&#xff09;<\/p>\n<p>\/\/ \u67e5\u627e XLink \u547d\u540d\u7a7a\u95f4\u7684\u524d\u7f00<br \/>\nlet xlinkPrefix &#061; document.lookupPrefix(&#039;http:\/\/www.w3.org\/1999\/xlink&#039;);<br \/>\nconsole.log(&#039;XLink \u524d\u7f00&#xff1a;&#039;, xlinkPrefix); \/\/ &#039;xlink&#039;<\/p>\n<p>\/\/ \u5b9e\u7528\u573a\u666f&#xff1a;\u6839\u636e URI \u83b7\u53d6\u524d\u7f00<br \/>\nfunction getPrefixForURI(uri) {<br \/>\n    let prefix &#061; document.lookupPrefix(uri);<br \/>\n    return prefix || &#039;(\u9ed8\u8ba4\u547d\u540d\u7a7a\u95f4)&#039;;<br \/>\n}\n<\/li>\n<\/ul>\n<hr \/>\n<h2>\u7b2c\u516b\u90e8\u5206&#xff1a;\u6587\u6863\u5199\u5165\u65b9\u6cd5&#xff08;4\u4e2a&#xff09;<\/h2>\n<h3>46\u3001document.open()<\/h3>\n<ul>\n<li>\n<p>\u542b\u4e49&#xff1a;\u6253\u5f00\u4e00\u4e2a\u6587\u6863\u6d41&#xff0c;\u51c6\u5907\u5199\u5165\u5185\u5bb9\u3002\u4f1a\u6e05\u7a7a\u5f53\u524d\u6587\u6863\u3002<\/p>\n<\/li>\n<li>\n<p>\u8bcd\u6e90&#xff1a;Open&#xff08;\u6253\u5f00&#xff09;\u3002<\/p>\n<\/li>\n<li>\n<p>\u8bed\u6cd5&#xff1a;document.open();<\/p>\n<\/li>\n<li>\n<p>\u53c2\u6570\u53ca\u8bf4\u660e&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u53ef\u4ee5\u63a5\u53d7\u53ef\u9009\u7684 MIME \u7c7b\u578b\u548c\u66ff\u6362\u53c2\u6570&#xff0c;\u4f46\u901a\u5e38\u4e0d\u4f20\u53c2\u3002<\/p>\n<\/li>\n<li>\n<p>\u8c03\u7528\u540e\u4f1a\u6e05\u7a7a\u5f53\u524d\u6587\u6863\u7684\u6240\u6709\u5185\u5bb9\u3002<\/p>\n<\/li>\n<li>\n<p>\u5371\u9669\u64cd\u4f5c&#xff1a;\u4f1a\u6e05\u9664\u5f53\u524d\u9875\u9762\u3002<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u4f8b\u5b50&#xff1a;<\/p>\n<p>\/\/ \u57fa\u672c\u7528\u6cd5&#xff08;\u6781\u5ea6\u5371\u9669&#xff01;&#xff09;<br \/>\n\/\/ document.open();<br \/>\n\/\/ document.write(&#039;&lt;h1&gt;\u65b0\u9875\u9762&lt;\/h1&gt;&#039;);<br \/>\n\/\/ document.close();<\/p>\n<p>\/\/ \u5728\u65b0\u7a97\u53e3\u4e2d\u4f7f\u7528<br \/>\nfunction openInNewWindow() {<br \/>\n    let newWindow &#061; window.open();<br \/>\n    newWindow.document.open();<br \/>\n    newWindow.document.write(&#096;<br \/>\n        &lt;!DOCTYPE html&gt;<br \/>\n        &lt;html&gt;<br \/>\n            &lt;head&gt;&lt;title&gt;\u65b0\u7a97\u53e3&lt;\/title&gt;&lt;\/head&gt;<br \/>\n            &lt;body&gt;<br \/>\n                &lt;h1&gt;\u52a8\u6001\u751f\u6210\u7684\u5185\u5bb9&lt;\/h1&gt;<br \/>\n                &lt;p&gt;\u5f53\u524d\u65f6\u95f4&#xff1a;${new Date()}&lt;\/p&gt;<br \/>\n            &lt;\/body&gt;<br \/>\n        &lt;\/html&gt;<br \/>\n    &#096;);<br \/>\n    newWindow.document.close();<br \/>\n}<\/p>\n<p>\/\/ \u5b89\u5168\u7528\u6cd5&#xff1a;\u4ec5\u5728\u9700\u8981\u5b8c\u5168\u91cd\u5199\u6587\u6863\u65f6\u4f7f\u7528<br \/>\nfunction resetDocument() {<br \/>\n    if (confirm(&#039;\u786e\u5b9a\u8981\u6e05\u7a7a\u9875\u9762\u5417&#xff1f;&#039;)) {<br \/>\n        document.open();<br \/>\n        document.write(&#039;&lt;h1&gt;\u9875\u9762\u5df2\u91cd\u7f6e&lt;\/h1&gt;&#039;);<br \/>\n        document.close();<br \/>\n    }<br \/>\n}\n<\/li>\n<\/ul>\n<h3>47\u3001document.close()<\/h3>\n<ul>\n<li>\n<p>\u542b\u4e49&#xff1a;\u5173\u95ed\u7531\u00a0open()\u00a0\u6253\u5f00\u7684\u6587\u6863\u6d41&#xff0c;\u5e76\u5b8c\u6210\u6587\u6863\u5199\u5165\u3002<\/p>\n<\/li>\n<li>\n<p>\u8bcd\u6e90&#xff1a;Close&#xff08;\u5173\u95ed&#xff09;\u3002<\/p>\n<\/li>\n<li>\n<p>\u8bed\u6cd5&#xff1a;document.close();<\/p>\n<\/li>\n<li>\n<p>\u53c2\u6570\u53ca\u8bf4\u660e&#xff1a;\u65e0\u53c2\u6570\u3002\u5fc5\u987b\u5728\u00a0write()\u00a0\u64cd\u4f5c\u5b8c\u6210\u540e\u8c03\u7528\u3002<\/p>\n<\/li>\n<li>\n<p>\u4f8b\u5b50&#xff1a;<\/p>\n<p>\/\/ \u914d\u5408 open \u548c write \u4f7f\u7528<br \/>\nfunction generatePDFView() {<br \/>\n    document.open();<br \/>\n    document.write(&#039;&lt;h1&gt;PDF \u67e5\u770b\u5668&lt;\/h1&gt;&#039;);<br \/>\n    document.write(&#039;&lt;embed src&#061;&#034;doc.pdf&#034; type&#061;&#034;application\/pdf&#034; width&#061;&#034;100%&#034; height&#061;&#034;600px&#034;&gt;&#039;);<br \/>\n    document.close(); \/\/ \u5b8c\u6210\u5199\u5165<br \/>\n}<\/p>\n<p>\/\/ \u9519\u8bef\u793a\u8303&#xff1a;\u5fd8\u8bb0 close \u53ef\u80fd\u5bfc\u81f4\u5185\u5bb9\u4e0d\u663e\u793a<br \/>\nfunction badExample() {<br \/>\n    document.open();<br \/>\n    document.write(&#039;\u8fd9\u6bb5\u6587\u5b57\u53ef\u80fd\u4e0d\u4f1a\u663e\u793a&#039;);<br \/>\n    \/\/ \u5fd8\u8bb0 document.close()<br \/>\n}\n<\/li>\n<\/ul>\n<h3>48\u3001document.write()<\/h3>\n<ul>\n<li>\n<p>\u542b\u4e49&#xff1a;\u5411\u6587\u6863\u4e2d\u5199\u5165 HTML \u6216 JavaScript \u4ee3\u7801\u3002<\/p>\n<\/li>\n<li>\n<p>\u8bcd\u6e90&#xff1a;Write&#xff08;\u5199\u5165&#xff09;\u3002<\/p>\n<\/li>\n<li>\n<p>\u8bed\u6cd5&#xff1a;document.write(markup);<\/p>\n<\/li>\n<li>\n<p>\u53c2\u6570\u53ca\u8bf4\u660e&#xff1a;<\/p>\n<ul>\n<li>\n<p>markup&#xff1a;\u8981\u5199\u5165\u7684 HTML \u5b57\u7b26\u4e32\u3002<\/p>\n<\/li>\n<li>\n<p>\u91cd\u8981\u8b66\u544a&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u5982\u679c\u5728\u9875\u9762\u52a0\u8f7d\u5b8c\u6210\u540e\u8c03\u7528&#xff0c;\u4f1a\u8986\u76d6\u6574\u4e2a\u6587\u6863\u3002<\/p>\n<\/li>\n<li>\n<p>\u5728 XHTML \u6587\u6863\u4e2d\u65e0\u6548\u3002<\/p>\n<\/li>\n<li>\n<p>\u73b0\u4ee3\u5f00\u53d1\u4e2d\u6781\u5c11\u4f7f\u7528&#xff0c;\u63a8\u8350\u4f7f\u7528 DOM \u64cd\u4f5c\u65b9\u6cd5\u3002<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u4f8b\u5b50&#xff1a;<\/p>\n<p>\/\/ \u5728\u6587\u6863\u52a0\u8f7d\u671f\u95f4\u4f7f\u7528&#xff08;\u4f20\u7edf\u7528\u6cd5&#xff09;<br \/>\n\/\/ &lt;script&gt;<br \/>\n\/\/   document.write(&#039;&lt;p&gt;\u5f53\u524d\u65f6\u95f4&#xff1a;&#039; &#043; new Date() &#043; &#039;&lt;\/p&gt;&#039;);<br \/>\n\/\/ &lt;\/script&gt;<\/p>\n<p>\/\/ \u5371\u9669\u7528\u6cd5&#xff1a;\u9875\u9762\u52a0\u8f7d\u5b8c\u6210\u540e\u8c03\u7528\u4f1a\u8986\u76d6\u9875\u9762<br \/>\ndocument.getElementById(&#039;btn&#039;).addEventListener(&#039;click&#039;, function() {<br \/>\n    \/\/ document.write(&#039;\u65b0\u5185\u5bb9&#039;); \/\/ \u8fd9\u6837\u4f1a\u6e05\u7a7a\u6574\u4e2a\u9875\u9762&#xff01;<br \/>\n});<\/p>\n<p>\/\/ \u7528\u4e8e\u52a0\u8f7d\u5907\u7528\u8d44\u6e90<br \/>\nif (!document.querySelector(&#039;script[src&#061;&#034;jquery.js&#034;]&#039;)) {<br \/>\n    document.write(&#039;&lt;script src&#061;&#034;jquery.js&#034;&gt;&lt;\\\\\/script&gt;&#039;);<br \/>\n}<\/p>\n<p>\/\/ \u73b0\u4ee3\u66ff\u4ee3\u65b9\u6848<br \/>\n\/\/ \u4f7f\u7528 innerHTML \u6216 DOM \u65b9\u6cd5<br \/>\nlet p &#061; document.createElement(&#039;p&#039;);<br \/>\np.textContent &#061; &#039;\u5f53\u524d\u65f6\u95f4&#xff1a;&#039; &#043; new Date();<br \/>\ndocument.body.appendChild(p);\n<\/li>\n<\/ul>\n<h3>49\u3001document.writeln()<\/h3>\n<ul>\n<li>\n<p>\u542b\u4e49&#xff1a;\u548c\u00a0write()\u00a0\u7c7b\u4f3c&#xff0c;\u4f46\u5728\u672b\u5c3e\u6dfb\u52a0\u4e00\u4e2a\u6362\u884c\u7b26\u3002<\/p>\n<\/li>\n<li>\n<p>\u8bcd\u6e90&#xff1a;Write&#xff08;\u5199\u5165&#xff09;&#043; Line&#xff08;\u884c&#xff09;\u3002<\/p>\n<\/li>\n<li>\n<p>\u8bed\u6cd5&#xff1a;document.writeln(markup);<\/p>\n<\/li>\n<li>\n<p>\u53c2\u6570\u53ca\u8bf4\u660e&#xff1a;<\/p>\n<ul>\n<li>\n<p>markup&#xff1a;\u8981\u5199\u5165\u7684 HTML \u5b57\u7b26\u4e32\u3002<\/p>\n<\/li>\n<li>\n<p>\u5728 HTML \u4e2d\u6362\u884c\u7b26\u901a\u5e38\u4e0d\u53ef\u89c1&#xff0c;\u4f46\u5728\u00a0&lt;pre&gt;\u00a0\u6807\u7b7e\u5185\u6216\u6587\u672c\u8282\u70b9\u4e2d\u6709\u6548\u3002<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u4f8b\u5b50&#xff1a;<\/p>\n<p>\/\/ \u5728 &lt;pre&gt; \u6807\u7b7e\u4e2d\u4f7f\u7528\u6709\u6548<br \/>\ndocument.write(&#039;&lt;pre&gt;&#039;);<br \/>\ndocument.writeln(&#039;\u7b2c\u4e00\u884c\u6587\u672c&#039;);<br \/>\ndocument.writeln(&#039;\u7b2c\u4e8c\u884c\u6587\u672c&#039;);<br \/>\ndocument.writeln(&#039;\u7b2c\u4e09\u884c\u6587\u672c&#039;);<br \/>\ndocument.write(&#039;&lt;\/pre&gt;&#039;);<\/p>\n<p>\/\/ \u67e5\u770b\u6e90\u7801\u65f6\u4f1a\u770b\u5230\u6362\u884c<br \/>\n\/\/ \u7b2c\u4e00\u884c\u6587\u672c\\\\n<br \/>\n\/\/ \u7b2c\u4e8c\u884c\u6587\u672c\\\\n<br \/>\n\/\/ \u7b2c\u4e09\u884c\u6587\u672c<\/p>\n<p>\/\/ \u751f\u6210\u6587\u672c\u6587\u4ef6\u5185\u5bb9<br \/>\nfunction generateTextFile() {<br \/>\n    let content &#061; &#039;&#039;;<br \/>\n    document.write(&#039;&lt;pre&gt;&#039;);<br \/>\n    document.writeln(&#039;\u59d3\u540d,\u5e74\u9f84,\u57ce\u5e02&#039;);<br \/>\n    document.writeln(&#039;\u5f20\u4e09,25,\u5317\u4eac&#039;);<br \/>\n    document.writeln(&#039;\u674e\u56db,30,\u4e0a\u6d77&#039;);<br \/>\n    document.write(&#039;&lt;\/pre&gt;&#039;);<br \/>\n}\n<\/li>\n<\/ul>\n<hr \/>\n<h2>\u7b2c\u4e5d\u90e8\u5206&#xff1a;\u9ad8\u7ea7\u65b9\u6cd5&#xff08;2\u4e2a&#xff09;<\/h2>\n<h3>50\u3001document.getAnimations()<\/h3>\n<ul>\n<li>\n<p>\u542b\u4e49&#xff1a;\u8fd4\u56de\u5f53\u524d\u6587\u6863\u4e2d\u6240\u6709\u6709\u6548\u7684\u52a8\u753b\u5bf9\u8c61&#xff08;\u5305\u62ec CSS \u52a8\u753b\u548c\u8fc7\u6e21&#xff09;\u3002<\/p>\n<\/li>\n<li>\n<p>\u8bcd\u6e90&#xff1a;Get&#xff08;\u83b7\u53d6&#xff09;&#043; Animations&#xff08;\u52a8\u753b&#xff09;\u3002<\/p>\n<\/li>\n<li>\n<p>\u8bed\u6cd5&#xff1a;let animations &#061; document.getAnimations();<\/p>\n<\/li>\n<li>\n<p>\u53c2\u6570\u53ca\u8bf4\u660e&#xff1a;\u65e0\u53c2\u6570\u3002<\/p>\n<\/li>\n<li>\n<p>\u8fd4\u56de\u503c&#xff1a;\u4e00\u4e2a\u00a0Array\u00a0\u6570\u7ec4&#xff0c;\u5305\u542b\u6240\u6709\u6b63\u5728\u8fd0\u884c\u7684\u00a0Animation\u00a0\u5bf9\u8c61\u3002<\/p>\n<\/li>\n<li>\n<p>\u4f8b\u5b50&#xff1a;<\/p>\n<p>\/\/ \u83b7\u53d6\u6240\u6709\u52a8\u753b<br \/>\nlet allAnimations &#061; document.getAnimations();<br \/>\nconsole.log(&#039;\u9875\u9762\u4e2d\u6709 &#039; &#043; allAnimations.length &#043; &#039; \u4e2a\u52a8\u753b&#039;);<\/p>\n<p>\/\/ \u6682\u505c\u6240\u6709\u52a8\u753b<br \/>\nfunction pauseAllAnimations() {<br \/>\n    document.getAnimations().forEach(animation &#061;&gt; {<br \/>\n        animation.pause();<br \/>\n    });<br \/>\n    console.log(&#039;\u6240\u6709\u52a8\u753b\u5df2\u6682\u505c&#039;);<br \/>\n}<\/p>\n<p>\/\/ \u6062\u590d\u6240\u6709\u52a8\u753b<br \/>\nfunction playAllAnimations() {<br \/>\n    document.getAnimations().forEach(animation &#061;&gt; {<br \/>\n        animation.play();<br \/>\n    });<br \/>\n}<\/p>\n<p>\/\/ \u83b7\u53d6\u7279\u5b9a\u5143\u7d20\u7684\u52a8\u753b<br \/>\nfunction getElementAnimations(element) {<br \/>\n    return document.getAnimations().filter(animation &#061;&gt;<br \/>\n        animation.effect &amp;&amp; animation.effect.target &#061;&#061;&#061; element<br \/>\n    );<br \/>\n}<\/p>\n<p>\/\/ \u5f53\u9875\u9762\u9690\u85cf\u65f6\u6682\u505c\u52a8\u753b&#xff08;\u6027\u80fd\u4f18\u5316&#xff09;<br \/>\ndocument.addEventListener(&#039;visibilitychange&#039;, () &#061;&gt; {<br \/>\n    if (document.hidden) {<br \/>\n        document.getAnimations().forEach(anim &#061;&gt; anim.pause());<br \/>\n    } else {<br \/>\n        document.getAnimations().forEach(anim &#061;&gt; anim.play());<br \/>\n    }<br \/>\n});<\/p>\n<p>\/\/ \u52a8\u753b\u5b8c\u6210\u65f6\u7684 Promise<br \/>\nasync function waitForAllAnimations() {<br \/>\n    let animations &#061; document.getAnimations();<br \/>\n    await Promise.all(animations.map(anim &#061;&gt; anim.finished));<br \/>\n    console.log(&#039;\u6240\u6709\u52a8\u753b\u5b8c\u6210&#039;);<br \/>\n}\n<\/li>\n<\/ul>\n<h3>51\u3001document.getBoxQuads()&#xff08;\u5b9e\u9a8c\u6027 API&#xff09;<\/h3>\n<ul>\n<li>\n<p>\u542b\u4e49&#xff1a;\u8fd4\u56de\u5143\u7d20\u7684\u76d2\u5b50\u56db\u8fb9\u5f62\u7684\u4fe1\u606f&#xff08;\u5b9e\u9a8c\u6027 API&#xff0c;\u652f\u6301\u5ea6\u6709\u9650&#xff09;\u3002<\/p>\n<\/li>\n<li>\n<p>\u8bcd\u6e90&#xff1a;Get&#xff08;\u83b7\u53d6&#xff09;&#043; Box&#xff08;\u76d2\u5b50&#xff09;&#043; Quads&#xff08;\u56db\u8fb9\u5f62&#xff09;\u3002<\/p>\n<\/li>\n<li>\n<p>\u8bed\u6cd5&#xff1a;let quads &#061; document.getBoxQuads(options);<\/p>\n<\/li>\n<li>\n<p>\u53c2\u6570\u53ca\u8bf4\u660e&#xff1a;<\/p>\n<ul>\n<li>\n<p>options&#xff08;\u53ef\u9009&#xff09;&#xff1a;\u914d\u7f6e\u5bf9\u8c61\u3002<\/p>\n<ul>\n<li>\n<p>box&#xff1a;\u6307\u5b9a\u54ea\u4e2a CSS \u76d2\u5b50&#xff0c;\u53ef\u9009\u503c&#xff1a;&#039;content&#039;\u3001&#039;padding&#039;\u3001&#039;border&#039;\u3001&#039;margin&#039;\u3002<\/p>\n<\/li>\n<li>\n<p>relativeTo&#xff1a;\u76f8\u5bf9\u4e8e\u54ea\u4e2a\u5143\u7d20\u8ba1\u7b97\u5750\u6807\u3002<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u8fd4\u56de\u503c&#xff1a;\u4e00\u4e2a\u00a0DOMQuad\u00a0\u6570\u7ec4&#xff0c;\u8868\u793a\u5143\u7d20\u7684\u51e0\u4f55\u4fe1\u606f\u3002<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u4f8b\u5b50&#xff1a;<\/p>\n<p>\/\/ \u6ce8\u610f&#xff1a;\u8fd9\u662f\u4e00\u4e2a\u5b9e\u9a8c\u6027 API&#xff0c;\u5f53\u524d\u6d4f\u89c8\u5668\u652f\u6301\u6709\u9650<\/p>\n<p>\/\/ \u83b7\u53d6\u5143\u7d20\u7684\u5185\u5bb9\u76d2\u5b50\u7684\u56db\u8fb9\u5f62<br \/>\nlet element &#061; document.getElementById(&#039;myElement&#039;);<br \/>\nif (element.getBoxQuads) {<br \/>\n    let quads &#061; element.getBoxQuads({ box: &#039;border&#039; });<\/p>\n<p>    quads.forEach((quad, index) &#061;&gt; {<br \/>\n        console.log(&#096;\u56db\u8fb9\u5f62 ${index &#043; 1}:&#096;, {<br \/>\n            p1: { x: quad.p1.x, y: quad.p1.y },<br \/>\n            p2: { x: quad.p2.x, y: quad.p2.y },<br \/>\n            p3: { x: quad.p3.x, y: quad.p3.y },<br \/>\n            p4: { x: quad.p4.x, y: quad.p4.y }<br \/>\n        });<\/p>\n<p>        \/\/ \u83b7\u53d6\u8fb9\u754c\u77e9\u5f62<br \/>\n        let bounds &#061; quad.getBounds();<br \/>\n        console.log(&#039;\u8fb9\u754c:&#039;, bounds);<br \/>\n    });<br \/>\n}<\/p>\n<p>\/\/ \u76f8\u5bf9\u4e8e\u89c6\u53e3\u83b7\u53d6\u4f4d\u7f6e<br \/>\nif (element.getBoxQuads) {<br \/>\n    let quads &#061; element.getBoxQuads({<br \/>\n        box: &#039;margin&#039;,<br \/>\n        relativeTo: document.querySelector(&#039;#container&#039;)<br \/>\n    });<br \/>\n}<\/p>\n<p>\/\/ \u68c0\u67e5\u5143\u7d20\u662f\u5426\u53d8\u5f62&#xff08;\u5b9e\u9a8c\u6027&#xff09;<br \/>\nfunction isElementTransformed(element) {<br \/>\n    if (!element.getBoxQuads) return false;<\/p>\n<p>    let quads &#061; element.getBoxQuads({ box: &#039;border&#039; });<br \/>\n    if (quads.length &#061;&#061;&#061; 0) return false;<\/p>\n<p>    let quad &#061; quads[0];<br \/>\n    \/\/ \u68c0\u67e5\u662f\u5426\u662f\u77e9\u5f62&#xff08;\u7b80\u5355\u5224\u65ad&#xff09;<br \/>\n    let isRect &#061;<br \/>\n        Math.abs(quad.p1.x &#8211; quad.p2.x) &gt; 0.1 &amp;&amp;<br \/>\n        Math.abs(quad.p2.y &#8211; quad.p3.y) &gt; 0.1 &amp;&amp;<br \/>\n        Math.abs(quad.p3.x &#8211; quad.p4.x) &gt; 0.1 &amp;&amp;<br \/>\n        Math.abs(quad.p4.y &#8211; quad.p1.y) &gt; 0.1;<\/p>\n<p>    return !isRect;<br \/>\n}\n<\/li>\n<\/ul>\n<hr \/>\n<h2 style=\"text-align:center\"><\/h2>\n<h2 style=\"text-align:center\">\u603b \u7ed3 \u5217 \u8868<\/h2>\n<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u4e0b\u9762\u5bf9\u4e0a\u9762\u8bb2\u89e3\u7684JavaScript \u7684document\u00a0\u5bf9\u8c61 51 \u4e2a\u5e38\u89c1\u7684\u65b9\u6cd5\u8fdb\u884c\u603b\u7ed3\u5217\u8868\u3002<\/p>\n<h4>\u7b2c\u4e00\u90e8\u5206&#xff1a;\u4e8b\u4ef6\u5904\u7406\u65b9\u6cd5&#xff08;4\u4e2a&#xff09;<\/h4>\n<table>\n<tr>\u65b9\u6cd5\u542b\u4e49\u8bcd\u6e90\u8bed\u6cd5\u53c2\u6570\u53ca\u8bf4\u660e<\/tr>\n<tbody>\n<tr>\n<td>1<\/td>\n<td>document.addEventListener()<\/td>\n<td>\u5411\u6587\u6863\u6dfb\u52a0\u4e8b\u4ef6\u76d1\u542c\u5668\u3002<\/td>\n<td>&#034;add&#034;&#xff08;\u6dfb\u52a0&#xff09;&#043; &#034;EventListener&#034;&#xff08;\u4e8b\u4ef6\u76d1\u542c\u5668&#xff09;<\/td>\n<td>document.addEventListener(type, listener, options);<\/td>\n<td>type: \u4e8b\u4ef6\u7c7b\u578b\u5b57\u7b26\u4e32&#xff08;\u5982&#034;click&#034;&#xff09;\u3002listener: \u4e8b\u4ef6\u89e6\u53d1\u65f6\u8981\u8c03\u7528\u7684\u51fd\u6570\u6216\u5bf9\u8c61\u3002options: \u53ef\u9009&#xff0c;\u914d\u7f6e\u5bf9\u8c61&#xff08;capture\u3001once\u3001passive&#xff09;\u6216\u5e03\u5c14\u503c&#xff08;\u8868\u793a\u662f\u5426\u5728\u6355\u83b7\u9636\u6bb5\u89e6\u53d1&#xff09;\u3002<\/td>\n<\/tr>\n<tr>\n<td>2<\/td>\n<td>document.removeEventListener()<\/td>\n<td>\u4ece\u6587\u6863\u79fb\u9664\u4e8b\u4ef6\u76d1\u542c\u5668\u3002<\/td>\n<td>&#034;remove&#034;&#xff08;\u79fb\u9664&#xff09;&#043; &#034;EventListener&#034;&#xff08;\u4e8b\u4ef6\u76d1\u542c\u5668&#xff09;<\/td>\n<td>document.removeEventListener(type, listener, options);<\/td>\n<td>type: \u8981\u79fb\u9664\u7684\u4e8b\u4ef6\u7c7b\u578b\u3002listener: \u8981\u79fb\u9664\u7684\u4e8b\u4ef6\u5904\u7406\u51fd\u6570\u3002options: \u53ef\u9009&#xff0c;\u4e0e\u6dfb\u52a0\u65f6\u76f8\u540c\u7684\u914d\u7f6e\u9009\u9879\u6216\u5e03\u5c14\u503c&#xff0c;\u5fc5\u987b\u4e0e\u6dfb\u52a0\u65f6\u5339\u914d\u624d\u80fd\u79fb\u9664\u3002<\/td>\n<\/tr>\n<tr>\n<td>3<\/td>\n<td>document.dispatchEvent()<\/td>\n<td>\u5411\u6587\u6863\u6d3e\u53d1\u4e00\u4e2a\u81ea\u5b9a\u4e49\u4e8b\u4ef6\u3002<\/td>\n<td>&#034;dispatch&#034;&#xff08;\u6d3e\u9063\u3001\u53d1\u9001&#xff09;&#043; &#034;Event&#034;&#xff08;\u4e8b\u4ef6&#xff09;<\/td>\n<td>let result &#061; document.dispatchEvent(event);<\/td>\n<td>event: \u8981\u6d3e\u53d1\u7684 Event \u5bf9\u8c61&#xff08;\u901a\u5e38\u7528\u00a0new Event()\u00a0\u6216\u00a0new CustomEvent()\u00a0\u521b\u5efa&#xff09;\u3002\u8fd4\u56de\u503c\u662f\u4e00\u4e2a\u5e03\u5c14\u503c&#xff0c;\u8868\u793a\u662f\u5426\u6709\u4e8b\u4ef6\u5904\u7406\u7a0b\u5e8f\u8c03\u7528\u4e86\u00a0preventDefault()\u3002<\/td>\n<\/tr>\n<tr>\n<td>4<\/td>\n<td>document.execCommand()<\/td>\n<td>\u5728\u53ef\u7f16\u8f91\u5185\u5bb9\u533a\u57df\u6267\u884c\u4e00\u4e2a\u547d\u4ee4\u3002<\/td>\n<td>&#034;exec&#034;&#xff08;\u6267\u884c&#xff09;&#043; &#034;Command&#034;&#xff08;\u547d\u4ee4&#xff09;<\/td>\n<td>document.execCommand(commandId, showUI, value);<\/td>\n<td>commandId: \u547d\u4ee4\u540d\u79f0\u5b57\u7b26\u4e32&#xff08;\u5982&#034;bold&#034;\u3001&#034;copy&#034;&#xff09;\u3002showUI: \u5e03\u5c14\u503c&#xff0c;\u662f\u5426\u663e\u793a\u7528\u6237\u754c\u9762&#xff08;\u901a\u5e38\u8bbe\u4e3a false&#xff09;\u3002value: \u53ef\u9009&#xff0c;\u67d0\u4e9b\u547d\u4ee4\u9700\u8981\u7684\u989d\u5916\u53c2\u6570&#xff08;\u5982\u63d2\u5165\u94fe\u63a5\u65f6\u7684 URL&#xff09;\u3002\u5df2\u5e9f\u5f03&#xff0c;\u4e0d\u5efa\u8bae\u4f7f\u7528\u3002<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>\u7b2c\u4e8c\u90e8\u5206&#xff1a;\u8282\u70b9\u5bfc\u5165\u4e0e\u91c7\u7528\u65b9\u6cd5&#xff08;2\u4e2a&#xff09;<\/h4>\n<table>\n<tr>\u65b9\u6cd5\u542b\u4e49\u8bcd\u6e90\u8bed\u6cd5\u53c2\u6570\u53ca\u8bf4\u660e<\/tr>\n<tbody>\n<tr>\n<td>5<\/td>\n<td>document.adoptNode()<\/td>\n<td>\u4ece\u5176\u4ed6\u6587\u6863\u4e2d\u91c7\u7eb3\u4e00\u4e2a\u8282\u70b9&#xff0c;\u4f7f\u5176\u5f52\u5c5e\u5230\u5f53\u524d\u6587\u6863\u3002<\/td>\n<td>&#034;adopt&#034;&#xff08;\u91c7\u7eb3\u3001\u6536\u517b&#xff09;<\/td>\n<td>let adoptedNode &#061; document.adoptNode(node);<\/td>\n<td>node: \u8981\u4ece\u5176\u4ed6\u6587\u6863\u4e2d\u91c7\u7eb3\u7684\u8282\u70b9\u3002\u91c7\u7eb3\u540e&#xff0c;\u539f\u6587\u6863\u4e2d\u7684\u8be5\u8282\u70b9\u4f1a\u88ab\u79fb\u9664\u3002\u8fd4\u56de\u503c\u662f\u88ab\u91c7\u7eb3\u7684\u8282\u70b9\u3002<\/td>\n<\/tr>\n<tr>\n<td>6<\/td>\n<td>document.importNode()<\/td>\n<td>\u4ece\u5176\u4ed6\u6587\u6863\u4e2d\u5bfc\u5165\u4e00\u4e2a\u8282\u70b9&#xff0c;\u4f46\u4fdd\u7559\u539f\u6587\u6863\u4e2d\u7684\u8282\u70b9\u3002<\/td>\n<td>&#034;import&#034;&#xff08;\u5bfc\u5165&#xff09;<\/td>\n<td>let importedNode &#061; document.importNode(node, deep);<\/td>\n<td>node: \u8981\u4ece\u5176\u4ed6\u6587\u6863\u4e2d\u5bfc\u5165\u7684\u8282\u70b9\u3002deep: \u5e03\u5c14\u503c&#xff0c;\u662f\u5426\u6df1\u62f7\u8d1d&#xff08;\u5bfc\u5165\u8282\u70b9\u53ca\u5176\u6240\u6709\u5b50\u8282\u70b9&#xff09;\u3002\u8fd4\u56de\u503c\u662f\u5bfc\u5165\u7684\u8282\u70b9\u526f\u672c\u3002<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>\u7b2c\u4e09\u90e8\u5206&#xff1a;\u8282\u70b9\u64cd\u4f5c\u65b9\u6cd5&#xff08;10\u4e2a&#xff09;<\/h4>\n<table>\n<tr>\u65b9\u6cd5\u542b\u4e49\u8bcd\u6e90\u8bed\u6cd5\u53c2\u6570\u53ca\u8bf4\u660e<\/tr>\n<tbody>\n<tr>\n<td>7<\/td>\n<td>document.appendChild()<\/td>\n<td>\u5411\u6587\u6863\u672b\u5c3e\u6dfb\u52a0\u4e00\u4e2a\u5b50\u8282\u70b9\u3002<\/td>\n<td>&#034;append&#034;&#xff08;\u8ffd\u52a0&#xff09;&#043; &#034;Child&#034;&#xff08;\u5b50\u8282\u70b9&#xff09;<\/td>\n<td>document.appendChild(node);<\/td>\n<td>node: \u8981\u6dfb\u52a0\u7684\u8282\u70b9\u3002\u6ce8\u610f&#xff1a;document\u00a0\u901a\u5e38\u4e0d\u5141\u8bb8\u76f4\u63a5\u6dfb\u52a0\u5b50\u8282\u70b9&#xff08;\u6839\u5143\u7d20\u552f\u4e00&#xff09;&#xff0c;\u5b9e\u9645\u4f7f\u7528\u4e2d\u66f4\u591a\u7528\u4e8e\u5143\u7d20\u8282\u70b9\u3002<\/td>\n<\/tr>\n<tr>\n<td>8<\/td>\n<td>document.cloneNode()<\/td>\n<td>\u514b\u9686\u6587\u6863\u8282\u70b9\u3002<\/td>\n<td>&#034;clone&#034;&#xff08;\u514b\u9686&#xff09;<\/td>\n<td>let clonedNode &#061; document.cloneNode(deep);<\/td>\n<td>deep: \u53ef\u9009\u5e03\u5c14\u503c&#xff0c;true \u8868\u793a\u6df1\u514b\u9686&#xff08;\u514b\u9686\u8282\u70b9\u53ca\u5176\u6240\u6709\u5b50\u8282\u70b9&#xff09;&#xff0c;false \u8868\u793a\u6d45\u514b\u9686&#xff08;\u53ea\u514b\u9686\u8282\u70b9\u672c\u8eab&#xff09;\u3002<\/td>\n<\/tr>\n<tr>\n<td>9<\/td>\n<td>document.insertBefore()<\/td>\n<td>\u5728\u53c2\u8003\u8282\u70b9\u4e4b\u524d\u63d2\u5165\u4e00\u4e2a\u5b50\u8282\u70b9\u3002<\/td>\n<td>&#034;insert&#034;&#xff08;\u63d2\u5165&#xff09;&#043; &#034;Before&#034;&#xff08;\u5728&#8230;\u4e4b\u524d&#xff09;<\/td>\n<td>document.insertBefore(newNode, referenceNode);<\/td>\n<td>newNode: \u8981\u63d2\u5165\u7684\u8282\u70b9\u3002referenceNode: \u53c2\u8003\u8282\u70b9&#xff08;\u5728\u6b64\u8282\u70b9\u4e4b\u524d\u63d2\u5165&#xff09;\u3002\u5982\u679c\u4e3a null&#xff0c;\u5219\u63d2\u5165\u5230\u672b\u5c3e\u3002<\/td>\n<\/tr>\n<tr>\n<td>10<\/td>\n<td>document.replaceChild()<\/td>\n<td>\u66ff\u6362\u6587\u6863\u4e2d\u7684\u4e00\u4e2a\u5b50\u8282\u70b9\u3002<\/td>\n<td>&#034;replace&#034;&#xff08;\u66ff\u6362&#xff09;&#043; &#034;Child&#034;&#xff08;\u5b50\u8282\u70b9&#xff09;<\/td>\n<td>let replacedNode &#061; document.replaceChild(newChild, oldChild);<\/td>\n<td>newChild: \u65b0\u8282\u70b9\u3002oldChild: \u8981\u88ab\u66ff\u6362\u7684\u65e7\u8282\u70b9\u3002\u8fd4\u56de\u503c\u662f\u88ab\u66ff\u6362\u7684\u65e7\u8282\u70b9\u3002<\/td>\n<\/tr>\n<tr>\n<td>11<\/td>\n<td>document.removeChild()<\/td>\n<td>\u4ece\u6587\u6863\u4e2d\u79fb\u9664\u4e00\u4e2a\u5b50\u8282\u70b9\u3002<\/td>\n<td>&#034;remove&#034;&#xff08;\u79fb\u9664&#xff09;&#043; &#034;Child&#034;&#xff08;\u5b50\u8282\u70b9&#xff09;<\/td>\n<td>let removedNode &#061; document.removeChild(node);<\/td>\n<td>node: \u8981\u79fb\u9664\u7684\u5b50\u8282\u70b9\u3002\u8fd4\u56de\u503c\u662f\u88ab\u79fb\u9664\u7684\u8282\u70b9\u3002<\/td>\n<\/tr>\n<tr>\n<td>12<\/td>\n<td>document.hasChildNodes()<\/td>\n<td>\u68c0\u67e5\u6587\u6863\u662f\u5426\u6709\u5b50\u8282\u70b9\u3002<\/td>\n<td>&#034;has&#034;&#xff08;\u6709&#xff09;&#043; &#034;Child&#034;&#xff08;\u5b50&#xff09;&#043; &#034;Nodes&#034;&#xff08;\u8282\u70b9\u4eec&#xff09;<\/td>\n<td>let hasChildren &#061; document.hasChildNodes();<\/td>\n<td>\u65e0\u53c2\u6570\u3002\u8fd4\u56de\u503c\u662f\u5e03\u5c14\u503c&#xff0c;true \u8868\u793a\u6709\u5b50\u8282\u70b9&#xff0c;false \u8868\u793a\u6ca1\u6709\u3002<\/td>\n<\/tr>\n<tr>\n<td>13<\/td>\n<td>document.normalize()<\/td>\n<td>\u5408\u5e76\u6587\u6863\u4e2d\u76f8\u90bb\u7684\u6587\u672c\u8282\u70b9\u5e76\u79fb\u9664\u7a7a\u6587\u672c\u8282\u70b9\u3002<\/td>\n<td>&#034;normalize&#034;&#xff08;\u89c4\u8303\u5316&#xff09;<\/td>\n<td>document.normalize();<\/td>\n<td>\u65e0\u53c2\u6570\u3002\u7528\u4e8e\u6e05\u7406\u6587\u6863\u6811\u4e2d\u7684\u6587\u672c\u8282\u70b9\u3002<\/td>\n<\/tr>\n<tr>\n<td>14<\/td>\n<td>document.prepend()<\/td>\n<td>\u5728\u6587\u6863\u7684\u7b2c\u4e00\u4e2a\u5b50\u8282\u70b9\u4e4b\u524d\u63d2\u5165\u4e00\u7ec4\u8282\u70b9\u6216\u5b57\u7b26\u4e32\u3002<\/td>\n<td>&#034;prepend&#034;&#xff08;\u5728\u524d\u9762\u9644\u52a0&#xff09;<\/td>\n<td>document.prepend(&#8230;nodesOrStrings);<\/td>\n<td>\u63a5\u53d7\u4e00\u4e2a\u6216\u591a\u4e2a\u53c2\u6570&#xff0c;\u53ef\u4ee5\u662f Node \u5bf9\u8c61\u6216\u5b57\u7b26\u4e32&#xff08;\u5b57\u7b26\u4e32\u4f1a\u81ea\u52a8\u8f6c\u6362\u4e3a\u6587\u672c\u8282\u70b9&#xff09;\u3002<\/td>\n<\/tr>\n<tr>\n<td>15<\/td>\n<td>document.append()<\/td>\n<td>\u5728\u6587\u6863\u7684\u6700\u540e\u4e00\u4e2a\u5b50\u8282\u70b9\u4e4b\u540e\u63d2\u5165\u4e00\u7ec4\u8282\u70b9\u6216\u5b57\u7b26\u4e32\u3002<\/td>\n<td>&#034;append&#034;&#xff08;\u8ffd\u52a0&#xff09;<\/td>\n<td>document.append(&#8230;nodesOrStrings);<\/td>\n<td>\u63a5\u53d7\u4e00\u4e2a\u6216\u591a\u4e2a\u53c2\u6570&#xff0c;\u53ef\u4ee5\u662f Node \u5bf9\u8c61\u6216\u5b57\u7b26\u4e32&#xff08;\u5b57\u7b26\u4e32\u4f1a\u81ea\u52a8\u8f6c\u6362\u4e3a\u6587\u672c\u8282\u70b9&#xff09;\u3002<\/td>\n<\/tr>\n<tr>\n<td>16<\/td>\n<td>document.replaceChildren()<\/td>\n<td>\u66ff\u6362\u6587\u6863\u7684\u6240\u6709\u5b50\u8282\u70b9\u3002<\/td>\n<td>&#034;replace&#034;&#xff08;\u66ff\u6362&#xff09;&#043; &#034;Children&#034;&#xff08;\u5b50\u8282\u70b9\u4eec&#xff09;<\/td>\n<td>document.replaceChildren(&#8230;nodesOrStrings);<\/td>\n<td>\u63a5\u53d7\u4e00\u4e2a\u6216\u591a\u4e2a\u53c2\u6570&#xff0c;\u53ef\u4ee5\u662f Node \u5bf9\u8c61\u6216\u5b57\u7b26\u4e32\u3002\u5982\u679c\u6ca1\u6709\u63d0\u4f9b\u53c2\u6570&#xff0c;\u5219\u6e05\u7a7a\u6240\u6709\u5b50\u8282\u70b9\u3002<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>\u7b2c\u56db\u90e8\u5206&#xff1a;\u6587\u6863\u72b6\u6001\u4e0e\u4ea4\u4e92\u65b9\u6cd5&#xff08;10\u4e2a&#xff09;<\/h4>\n<table>\n<tr>\u65b9\u6cd5\u542b\u4e49\u8bcd\u6e90\u8bed\u6cd5\u53c2\u6570\u53ca\u8bf4\u660e<\/tr>\n<tbody>\n<tr>\n<td>17<\/td>\n<td>document.hasFocus()<\/td>\n<td>\u68c0\u67e5\u6587\u6863\u6216\u6587\u6863\u5185\u7684\u4efb\u4f55\u5143\u7d20\u662f\u5426\u83b7\u5f97\u7126\u70b9\u3002<\/td>\n<td>&#034;has&#034;&#xff08;\u6709&#xff09;&#043; &#034;Focus&#034;&#xff08;\u7126\u70b9&#xff09;<\/td>\n<td>let focused &#061; document.hasFocus();<\/td>\n<td>\u65e0\u53c2\u6570\u3002\u8fd4\u56de\u503c\u662f\u5e03\u5c14\u503c&#xff0c;true \u8868\u793a\u6587\u6863\u83b7\u5f97\u7126\u70b9\u3002<\/td>\n<\/tr>\n<tr>\n<td>18<\/td>\n<td>document.getElementById()<\/td>\n<td>\u901a\u8fc7 id \u5c5e\u6027\u83b7\u53d6\u5143\u7d20\u3002<\/td>\n<td>&#034;get&#034;&#xff08;\u83b7\u53d6&#xff09;&#043; &#034;Element&#034;&#xff08;\u5143\u7d20&#xff09;&#043; &#034;ById&#034;&#xff08;\u901a\u8fc7Id&#xff09;<\/td>\n<td>let element &#061; document.getElementById(id);<\/td>\n<td>id: \u5b57\u7b26\u4e32&#xff0c;\u8981\u67e5\u627e\u7684\u5143\u7d20 id \u5c5e\u6027\u503c\u3002\u8fd4\u56de\u503c\u662f\u5339\u914d\u7684 Element \u5bf9\u8c61&#xff0c;\u5982\u679c\u6ca1\u6709\u5219\u8fd4\u56de null\u3002<\/td>\n<\/tr>\n<tr>\n<td>19<\/td>\n<td>document.getElementsByClassName()<\/td>\n<td>\u901a\u8fc7\u7c7b\u540d\u83b7\u53d6\u5143\u7d20\u96c6\u5408\u3002<\/td>\n<td>&#034;get&#034;&#xff08;\u83b7\u53d6&#xff09;&#043; &#034;Elements&#034;&#xff08;\u5143\u7d20\u4eec&#xff09;&#043; &#034;ByClassName&#034;&#xff08;\u901a\u8fc7\u7c7b\u540d&#xff09;<\/td>\n<td>let elements &#061; document.getElementsByClassName(names);<\/td>\n<td>names: \u5b57\u7b26\u4e32&#xff0c;\u5305\u542b\u4e00\u4e2a\u6216\u591a\u4e2a\u7c7b\u540d\u7684\u7a7a\u683c\u5206\u9694\u5217\u8868\u3002\u8fd4\u56de\u503c\u4e3a\u52a8\u6001\u66f4\u65b0\u7684 HTMLCollection\u3002<\/td>\n<\/tr>\n<tr>\n<td>20<\/td>\n<td>document.getElementsByName()<\/td>\n<td>\u901a\u8fc7 name \u5c5e\u6027\u83b7\u53d6\u5143\u7d20\u96c6\u5408\u3002<\/td>\n<td>&#034;get&#034;&#xff08;\u83b7\u53d6&#xff09;&#043; &#034;Elements&#034;&#xff08;\u5143\u7d20\u4eec&#xff09;&#043; &#034;ByName&#034;&#xff08;\u901a\u8fc7\u540d\u5b57&#xff09;<\/td>\n<td>let elements &#061; document.getElementsByName(name);<\/td>\n<td>name: \u5b57\u7b26\u4e32&#xff0c;\u5143\u7d20\u7684 name \u5c5e\u6027\u503c\u3002\u8fd4\u56de\u503c\u4e3a NodeList\u3002<\/td>\n<\/tr>\n<tr>\n<td>21<\/td>\n<td>document.getElementsByTagName()<\/td>\n<td>\u901a\u8fc7\u6807\u7b7e\u540d\u83b7\u53d6\u5143\u7d20\u96c6\u5408\u3002<\/td>\n<td>&#034;get&#034;&#xff08;\u83b7\u53d6&#xff09;&#043; &#034;Elements&#034;&#xff08;\u5143\u7d20\u4eec&#xff09;&#043; &#034;ByTagName&#034;&#xff08;\u901a\u8fc7\u6807\u7b7e\u540d&#xff09;<\/td>\n<td>let elements &#061; document.getElementsByTagName(tagName);<\/td>\n<td>tagName: \u5b57\u7b26\u4e32&#xff0c;\u6807\u7b7e\u540d&#xff08;\u5982&#034;div&#034;&#xff09;\u3002\u53ef\u4f7f\u7528&#034;*&#034;\u5339\u914d\u6240\u6709\u5143\u7d20\u3002\u8fd4\u56de\u503c\u4e3a\u52a8\u6001\u66f4\u65b0\u7684 HTMLCollection\u3002<\/td>\n<\/tr>\n<tr>\n<td>22<\/td>\n<td>document.getElementsByTagNameNS()<\/td>\n<td>\u901a\u8fc7\u547d\u540d\u7a7a\u95f4\u548c\u6807\u7b7e\u540d\u83b7\u53d6\u5143\u7d20\u96c6\u5408\u3002<\/td>\n<td>&#034;get&#034;&#xff08;\u83b7\u53d6&#xff09;&#043; &#034;Elements&#034;&#xff08;\u5143\u7d20\u4eec&#xff09;&#043; &#034;ByTagNameNS&#034;&#xff08;\u901a\u8fc7\u6807\u7b7e\u540d&#043;\u547d\u540d\u7a7a\u95f4&#xff09;<\/td>\n<td>let elements &#061; document.getElementsByTagNameNS(namespace, tagName);<\/td>\n<td>namespace: \u5b57\u7b26\u4e32&#xff0c;\u5143\u7d20\u7684\u547d\u540d\u7a7a\u95f4 URI\u3002tagName: \u5b57\u7b26\u4e32&#xff0c;\u6807\u7b7e\u540d\u3002\u8fd4\u56de\u503c\u4e3a NodeList\u3002<\/td>\n<\/tr>\n<tr>\n<td>23<\/td>\n<td>document.querySelector()<\/td>\n<td>\u8fd4\u56de\u5339\u914d\u6307\u5b9a CSS \u9009\u62e9\u5668\u7684\u7b2c\u4e00\u4e2a\u5143\u7d20\u3002<\/td>\n<td>&#034;query&#034;&#xff08;\u67e5\u8be2&#xff09;&#043; &#034;Selector&#034;&#xff08;\u9009\u62e9\u5668&#xff09;<\/td>\n<td>let element &#061; document.querySelector(selectors);<\/td>\n<td>selectors: \u5b57\u7b26\u4e32&#xff0c;CSS \u9009\u62e9\u5668\u3002\u8fd4\u56de\u503c\u662f\u5339\u914d\u7684\u7b2c\u4e00\u4e2a Element \u5bf9\u8c61&#xff0c;\u5982\u679c\u6ca1\u6709\u5219\u8fd4\u56de null\u3002<\/td>\n<\/tr>\n<tr>\n<td>24<\/td>\n<td>document.querySelectorAll()<\/td>\n<td>\u8fd4\u56de\u5339\u914d\u6307\u5b9a CSS \u9009\u62e9\u5668\u7684\u6240\u6709\u5143\u7d20\u7684\u9759\u6001 NodeList\u3002<\/td>\n<td>&#034;query&#034;&#xff08;\u67e5\u8be2&#xff09;&#043; &#034;Selector&#034;&#xff08;\u9009\u62e9\u5668&#xff09;&#043; &#034;All&#034;&#xff08;\u6240\u6709&#xff09;<\/td>\n<td>let elementList &#061; document.querySelectorAll(selectors);<\/td>\n<td>selectors: \u5b57\u7b26\u4e32&#xff0c;CSS \u9009\u62e9\u5668\u3002\u8fd4\u56de\u503c\u4e3a\u9759\u6001\u7684&#xff08;\u975e\u52a8\u6001&#xff09;NodeList\u3002<\/td>\n<\/tr>\n<tr>\n<td>25<\/td>\n<td>document.getSelection()<\/td>\n<td>\u8fd4\u56de\u7528\u6237\u5f53\u524d\u9009\u4e2d\u7684\u6587\u672c\u8303\u56f4\u3002<\/td>\n<td>&#034;get&#034;&#xff08;\u83b7\u53d6&#xff09;&#043; &#034;Selection&#034;&#xff08;\u9009\u62e9\u533a\u57df&#xff09;<\/td>\n<td>let selection &#061; document.getSelection();<\/td>\n<td>\u65e0\u53c2\u6570\u3002\u8fd4\u56de\u503c\u662f\u4e00\u4e2a Selection \u5bf9\u8c61&#xff0c;\u5305\u542b\u9009\u4e2d\u7684\u6587\u672c\u4fe1\u606f\u3002<\/td>\n<\/tr>\n<tr>\n<td>26<\/td>\n<td>document.exitFullscreen()<\/td>\n<td>\u9000\u51fa\u5168\u5c4f\u6a21\u5f0f\u3002<\/td>\n<td>&#034;exit&#034;&#xff08;\u9000\u51fa&#xff09;&#043; &#034;Fullscreen&#034;&#xff08;\u5168\u5c4f&#xff09;<\/td>\n<td>document.exitFullscreen();<\/td>\n<td>\u65e0\u53c2\u6570\u3002\u8fd4\u56de\u4e00\u4e2a Promise&#xff0c;\u5728\u5168\u5c4f\u9000\u51fa\u540e\u5151\u73b0\u3002<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>\u7b2c\u4e94\u90e8\u5206&#xff1a;\u5750\u6807\u4e0e\u8303\u56f4\u65b9\u6cd5&#xff08;6\u4e2a&#xff09;<\/h4>\n<table>\n<tr>\u65b9\u6cd5\u542b\u4e49\u8bcd\u6e90\u8bed\u6cd5\u53c2\u6570\u53ca\u8bf4\u660e<\/tr>\n<tbody>\n<tr>\n<td>27<\/td>\n<td>document.elementFromPoint()<\/td>\n<td>\u8fd4\u56de\u89c6\u53e3\u4e2d\u6307\u5b9a\u5750\u6807\u70b9\u6700\u4e0a\u5c42\u7684\u5143\u7d20\u3002<\/td>\n<td>&#034;element&#034;&#xff08;\u5143\u7d20&#xff09;&#043; &#034;from&#034;&#xff08;\u4ece&#xff09;&#043; &#034;point&#034;&#xff08;\u70b9&#xff09;<\/td>\n<td>let element &#061; document.elementFromPoint(x, y);<\/td>\n<td>x: \u76f8\u5bf9\u4e8e\u89c6\u53e3\u5de6\u8fb9\u754c\u7684\u6c34\u5e73\u5750\u6807\u3002y: \u76f8\u5bf9\u4e8e\u89c6\u53e3\u4e0a\u8fb9\u754c\u7684\u5782\u76f4\u5750\u6807\u3002\u8fd4\u56de\u503c\u662f\u4f4d\u4e8e\u8be5\u70b9\u7684\u6700\u4e0a\u5c42 Element\u3002<\/td>\n<\/tr>\n<tr>\n<td>28<\/td>\n<td>document.elementsFromPoint()<\/td>\n<td>\u8fd4\u56de\u89c6\u53e3\u4e2d\u6307\u5b9a\u5750\u6807\u70b9\u7684\u6240\u6709\u5143\u7d20\u7684\u6570\u7ec4\u3002<\/td>\n<td>&#034;elements&#034;&#xff08;\u5143\u7d20\u4eec&#xff09;&#043; &#034;from&#034;&#xff08;\u4ece&#xff09;&#043; &#034;point&#034;&#xff08;\u70b9&#xff09;<\/td>\n<td>let elements &#061; document.elementsFromPoint(x, y);<\/td>\n<td>x: \u76f8\u5bf9\u4e8e\u89c6\u53e3\u5de6\u8fb9\u754c\u7684\u6c34\u5e73\u5750\u6807\u3002y: \u76f8\u5bf9\u4e8e\u89c6\u53e3\u4e0a\u8fb9\u754c\u7684\u5782\u76f4\u5750\u6807\u3002\u8fd4\u56de\u503c\u662f\u4e00\u4e2a\u5305\u542b\u6240\u6709\u8986\u76d6\u8be5\u70b9\u7684\u5143\u7d20\u7684\u6570\u7ec4\u3002<\/td>\n<\/tr>\n<tr>\n<td>29<\/td>\n<td>document.getClientRects()<\/td>\n<td>\u8fd4\u56de\u6587\u6863\u4e2d\u6587\u672c\u77e9\u5f62\u96c6\u5408\u3002<\/td>\n<td>&#034;get&#034;&#xff08;\u83b7\u53d6&#xff09;&#043; &#034;ClientRects&#034;&#xff08;\u5ba2\u6237\u7aef\u77e9\u5f62\u533a\u57df&#xff09;<\/td>\n<td>let rectCollection &#061; document.getClientRects();<\/td>\n<td>\u65e0\u53c2\u6570\u3002\u901a\u5e38\u7528\u4e8e\u6587\u672c\u8282\u70b9&#xff0c;\u8fd4\u56de\u4e00\u4e2a DOMRectList \u96c6\u5408\u3002<\/td>\n<\/tr>\n<tr>\n<td>30<\/td>\n<td>document.createRange()<\/td>\n<td>\u521b\u5efa\u4e00\u4e2a\u65b0\u7684 Range \u5bf9\u8c61\u3002<\/td>\n<td>&#034;create&#034;&#xff08;\u521b\u5efa&#xff09;&#043; &#034;Range&#034;&#xff08;\u8303\u56f4&#xff09;<\/td>\n<td>let range &#061; document.createRange();<\/td>\n<td>\u65e0\u53c2\u6570\u3002\u8fd4\u56de\u4e00\u4e2a\u7a7a\u7684 Range \u5bf9\u8c61&#xff0c;\u53ef\u7528\u4e8e\u9009\u53d6\u6587\u6863\u7684\u4e00\u90e8\u5206\u3002<\/td>\n<\/tr>\n<tr>\n<td>31<\/td>\n<td>document.caretPositionFromPoint()<\/td>\n<td>\u8fd4\u56de\u6307\u5b9a\u5750\u6807\u70b9\u7684\u63d2\u5165\u7b26\u53f7\u4f4d\u7f6e\u3002<\/td>\n<td>&#034;caret&#034;&#xff08;\u5149\u6807&#xff09;&#043; &#034;position&#034;&#xff08;\u4f4d\u7f6e&#xff09;&#043; &#034;from&#034;&#xff08;\u4ece&#xff09;&#043; &#034;point&#034;&#xff08;\u70b9&#xff09;<\/td>\n<td>let caretPos &#061; document.caretPositionFromPoint(x, y);<\/td>\n<td>x: \u6c34\u5e73\u5750\u6807\u3002y: \u5782\u76f4\u5750\u6807\u3002\u8fd4\u56de\u4e00\u4e2a CaretPosition \u5bf9\u8c61&#xff0c;\u5305\u542b\u8282\u70b9\u548c\u504f\u79fb\u91cf\u3002<\/td>\n<\/tr>\n<tr>\n<td>32<\/td>\n<td>document.evaluate()<\/td>\n<td>\u6267\u884c XPath \u8868\u8fbe\u5f0f\u5e76\u8fd4\u56de\u7ed3\u679c\u3002<\/td>\n<td>&#034;evaluate&#034;&#xff08;\u8bc4\u4f30\u3001\u8ba1\u7b97&#xff09;<\/td>\n<td>let result &#061; document.evaluate(xpathExpression, contextNode, namespaceResolver, resultType, result);<\/td>\n<td>xpathExpression: XPath \u8868\u8fbe\u5f0f\u5b57\u7b26\u4e32\u3002contextNode: \u4e0a\u4e0b\u6587\u8282\u70b9\u3002namespaceResolver: \u547d\u540d\u7a7a\u95f4\u89e3\u6790\u51fd\u6570\u3002resultType: \u8fd4\u56de\u7ed3\u679c\u7c7b\u578b\u5e38\u91cf\u3002result: \u53ef\u91cd\u7528\u7684 XPathResult \u5bf9\u8c61\u3002<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>\u7b2c\u516d\u90e8\u5206&#xff1a;\u521b\u5efa\u65b9\u6cd5&#xff08;6\u4e2a&#xff09;<\/h4>\n<table>\n<tr>\u65b9\u6cd5\u542b\u4e49\u8bcd\u6e90\u8bed\u6cd5\u53c2\u6570\u53ca\u8bf4\u660e<\/tr>\n<tbody>\n<tr>\n<td>33<\/td>\n<td>document.createAttribute()<\/td>\n<td>\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u5c5e\u6027\u8282\u70b9\u3002<\/td>\n<td>&#034;create&#034;&#xff08;\u521b\u5efa&#xff09;&#043; &#034;Attribute&#034;&#xff08;\u5c5e\u6027&#xff09;<\/td>\n<td>let attr &#061; document.createAttribute(name);<\/td>\n<td>name: \u5b57\u7b26\u4e32&#xff0c;\u5c5e\u6027\u7684\u540d\u79f0\u3002\u8fd4\u56de\u503c\u662f\u4e00\u4e2a Attr \u8282\u70b9\u3002\u5df2\u5e9f\u5f03&#xff0c;\u63a8\u8350\u4f7f\u7528\u00a0setAttribute()\u3002<\/td>\n<\/tr>\n<tr>\n<td>34<\/td>\n<td>document.createComment()<\/td>\n<td>\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u6ce8\u91ca\u8282\u70b9\u3002<\/td>\n<td>&#034;create&#034;&#xff08;\u521b\u5efa&#xff09;&#043; &#034;Comment&#034;&#xff08;\u6ce8\u91ca&#xff09;<\/td>\n<td>let comment &#061; document.createComment(data);<\/td>\n<td>data: \u5b57\u7b26\u4e32&#xff0c;\u6ce8\u91ca\u5185\u5bb9\u3002\u8fd4\u56de\u503c\u662f\u4e00\u4e2a Comment \u8282\u70b9\u3002<\/td>\n<\/tr>\n<tr>\n<td>35<\/td>\n<td>document.createDocumentFragment()<\/td>\n<td>\u521b\u5efa\u4e00\u4e2a\u7a7a\u7684\u6587\u6863\u7247\u6bb5\u3002<\/td>\n<td>&#034;create&#034;&#xff08;\u521b\u5efa&#xff09;&#043; &#034;DocumentFragment&#034;&#xff08;\u6587\u6863\u7247\u6bb5&#xff09;<\/td>\n<td>let fragment &#061; document.createDocumentFragment();<\/td>\n<td>\u65e0\u53c2\u6570\u3002\u8fd4\u56de\u4e00\u4e2a\u7a7a\u7684 DocumentFragment \u8282\u70b9&#xff0c;\u53ef\u7528\u4e8e\u6279\u91cf\u64cd\u4f5c DOM\u3002<\/td>\n<\/tr>\n<tr>\n<td>36<\/td>\n<td>document.createEvent()<\/td>\n<td>\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u4e8b\u4ef6\u5bf9\u8c61\u3002<\/td>\n<td>&#034;create&#034;&#xff08;\u521b\u5efa&#xff09;&#043; &#034;Event&#034;&#xff08;\u4e8b\u4ef6&#xff09;<\/td>\n<td>let event &#061; document.createEvent(eventType);<\/td>\n<td>eventType: \u5b57\u7b26\u4e32&#xff0c;\u4e8b\u4ef6\u7c7b\u578b&#xff08;\u5982&#034;MouseEvent&#034;&#xff09;\u3002\u5df2\u5e9f\u5f03&#xff0c;\u63a8\u8350\u4f7f\u7528\u00a0new Event()\u00a0\u6784\u9020\u51fd\u6570\u3002<\/td>\n<\/tr>\n<tr>\n<td>37<\/td>\n<td>document.createElement()<\/td>\n<td>\u521b\u5efa\u4e00\u4e2a\u6307\u5b9a\u6807\u7b7e\u540d\u7684\u5143\u7d20\u8282\u70b9\u3002<\/td>\n<td>&#034;create&#034;&#xff08;\u521b\u5efa&#xff09;&#043; &#034;Element&#034;&#xff08;\u5143\u7d20&#xff09;<\/td>\n<td>let element &#061; document.createElement(tagName, options);<\/td>\n<td>tagName: \u5b57\u7b26\u4e32&#xff0c;\u8981\u521b\u5efa\u7684\u5143\u7d20\u7684\u6807\u7b7e\u540d\u3002options: \u53ef\u9009\u914d\u7f6e\u5bf9\u8c61&#xff08;\u5982\u00a0{ is: &#034;custom-element&#034; }&#xff09;\u3002\u8fd4\u56de\u65b0\u7684 Element \u5bf9\u8c61\u3002<\/td>\n<\/tr>\n<tr>\n<td>38<\/td>\n<td>document.createTextNode()<\/td>\n<td>\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u6587\u672c\u8282\u70b9\u3002<\/td>\n<td>&#034;create&#034;&#xff08;\u521b\u5efa&#xff09;&#043; &#034;TextNode&#034;&#xff08;\u6587\u672c\u8282\u70b9&#xff09;<\/td>\n<td>let textNode &#061; document.createTextNode(data);<\/td>\n<td>data: \u5b57\u7b26\u4e32&#xff0c;\u6587\u672c\u8282\u70b9\u7684\u5185\u5bb9\u3002\u8fd4\u56de\u503c\u662f\u4e00\u4e2a Text \u8282\u70b9\u3002<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>\u7b2c\u4e03\u90e8\u5206&#xff1a;\u6bd4\u8f83\u4e0e\u547d\u540d\u7a7a\u95f4\u65b9\u6cd5&#xff08;7\u4e2a&#xff09;<\/h4>\n<table>\n<tr>\u65b9\u6cd5\u542b\u4e49\u8bcd\u6e90\u8bed\u6cd5\u53c2\u6570\u53ca\u8bf4\u660e<\/tr>\n<tbody>\n<tr>\n<td>39<\/td>\n<td>document.compareDocumentPosition()<\/td>\n<td>\u6bd4\u8f83\u5f53\u524d\u6587\u6863\u8282\u70b9\u4e0e\u53e6\u4e00\u4e2a\u8282\u70b9\u7684\u4f4d\u7f6e\u5173\u7cfb\u3002<\/td>\n<td>&#034;compare&#034;&#xff08;\u6bd4\u8f83&#xff09;&#043; &#034;DocumentPosition&#034;&#xff08;\u6587\u6863\u4f4d\u7f6e&#xff09;<\/td>\n<td>let position &#061; document.compareDocumentPosition(otherNode);<\/td>\n<td>otherNode: \u8981\u6bd4\u8f83\u7684\u53e6\u4e00\u4e2a\u8282\u70b9\u3002\u8fd4\u56de\u503c\u662f\u8868\u793a\u4f4d\u7f6e\u5173\u7cfb\u7684\u4f4d\u63a9\u7801&#xff08;\u5982\u00a0Node.DOCUMENT_POSITION_FOLLOWING&#xff09;\u3002<\/td>\n<\/tr>\n<tr>\n<td>40<\/td>\n<td>document.contains()<\/td>\n<td>\u68c0\u67e5\u4e00\u4e2a\u8282\u70b9\u662f\u5426\u662f\u5f53\u524d\u6587\u6863\u8282\u70b9\u7684\u540e\u4ee3\u3002<\/td>\n<td>&#034;contains&#034;&#xff08;\u5305\u542b&#xff09;<\/td>\n<td>let isContained &#061; document.contains(otherNode);<\/td>\n<td>otherNode: \u8981\u68c0\u67e5\u7684\u8282\u70b9\u3002\u8fd4\u56de\u503c\u662f\u5e03\u5c14\u503c&#xff0c;true \u8868\u793a\u8be5\u8282\u70b9\u662f\u540e\u4ee3\u3002<\/td>\n<\/tr>\n<tr>\n<td>41<\/td>\n<td>document.isDefaultNamespace()<\/td>\n<td>\u68c0\u67e5\u6307\u5b9a\u7684\u547d\u540d\u7a7a\u95f4 URI \u662f\u5426\u662f\u5f53\u524d\u6587\u6863\u7684\u9ed8\u8ba4\u547d\u540d\u7a7a\u95f4\u3002<\/td>\n<td>&#034;is&#034;&#xff08;\u662f&#xff09;&#043; &#034;DefaultNamespace&#034;&#xff08;\u9ed8\u8ba4\u547d\u540d\u7a7a\u95f4&#xff09;<\/td>\n<td>let isDefault &#061; document.isDefaultNamespace(namespaceURI);<\/td>\n<td>namespaceURI: \u8981\u68c0\u67e5\u7684\u547d\u540d\u7a7a\u95f4 URI \u5b57\u7b26\u4e32\u3002\u8fd4\u56de\u503c\u662f\u5e03\u5c14\u503c\u3002<\/td>\n<\/tr>\n<tr>\n<td>42<\/td>\n<td>document.isEqualNode()<\/td>\n<td>\u68c0\u67e5\u4e24\u4e2a\u8282\u70b9\u662f\u5426\u76f8\u7b49&#xff08;\u7c7b\u578b\u3001\u5c5e\u6027\u3001\u5b50\u8282\u70b9\u76f8\u540c&#xff09;\u3002<\/td>\n<td>&#034;is&#034;&#xff08;\u662f&#xff09;&#043; &#034;Equal&#034;&#xff08;\u76f8\u7b49&#xff09;&#043; &#034;Node&#034;&#xff08;\u8282\u70b9&#xff09;<\/td>\n<td>let isEqual &#061; document.isEqualNode(otherNode);<\/td>\n<td>otherNode: \u8981\u6bd4\u8f83\u7684\u53e6\u4e00\u4e2a\u8282\u70b9\u3002\u8fd4\u56de\u503c\u662f\u5e03\u5c14\u503c\u3002<\/td>\n<\/tr>\n<tr>\n<td>43<\/td>\n<td>document.isSameNode()<\/td>\n<td>\u68c0\u67e5\u4e24\u4e2a\u8282\u70b9\u662f\u5426\u4e3a\u540c\u4e00\u4e2a\u8282\u70b9\u5f15\u7528\u3002<\/td>\n<td>&#034;is&#034;&#xff08;\u662f&#xff09;&#043; &#034;Same&#034;&#xff08;\u76f8\u540c&#xff09;&#043; &#034;Node&#034;&#xff08;\u8282\u70b9&#xff09;<\/td>\n<td>let isSame &#061; document.isSameNode(otherNode);<\/td>\n<td>otherNode: \u8981\u6bd4\u8f83\u7684\u53e6\u4e00\u4e2a\u8282\u70b9\u3002\u8fd4\u56de\u503c\u662f\u5e03\u5c14\u503c\u3002<\/td>\n<\/tr>\n<tr>\n<td>44<\/td>\n<td>document.lookupNamespaceURI()<\/td>\n<td>\u8fd4\u56de\u4e0e\u7ed9\u5b9a\u524d\u7f00\u5173\u8054\u7684\u547d\u540d\u7a7a\u95f4 URI\u3002<\/td>\n<td>&#034;lookup&#034;&#xff08;\u67e5\u627e&#xff09;&#043; &#034;NamespaceURI&#034;&#xff08;\u547d\u540d\u7a7a\u95f4URI&#xff09;<\/td>\n<td>let uri &#061; document.lookupNamespaceURI(prefix);<\/td>\n<td>prefix: \u8981\u67e5\u627e\u7684\u524d\u7f00\u5b57\u7b26\u4e32\u3002\u8fd4\u56de\u503c\u662f\u5bf9\u5e94\u7684\u547d\u540d\u7a7a\u95f4 URI \u6216 null\u3002<\/td>\n<\/tr>\n<tr>\n<td>45<\/td>\n<td>document.lookupPrefix()<\/td>\n<td>\u8fd4\u56de\u4e0e\u7ed9\u5b9a\u547d\u540d\u7a7a\u95f4 URI \u5173\u8054\u7684\u524d\u7f00\u3002<\/td>\n<td>&#034;lookup&#034;&#xff08;\u67e5\u627e&#xff09;&#043; &#034;Prefix&#034;&#xff08;\u524d\u7f00&#xff09;<\/td>\n<td>let prefix &#061; document.lookupPrefix(namespaceURI);<\/td>\n<td>namespaceURI: \u8981\u67e5\u627e\u7684\u547d\u540d\u7a7a\u95f4 URI \u5b57\u7b26\u4e32\u3002\u8fd4\u56de\u503c\u662f\u5bf9\u5e94\u7684\u524d\u7f00\u6216 null\u3002<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>\u7b2c\u516b\u90e8\u5206&#xff1a;\u6587\u6863\u5199\u5165\u65b9\u6cd5&#xff08;4\u4e2a&#xff09;<\/h4>\n<table>\n<tr>\u65b9\u6cd5\u542b\u4e49\u8bcd\u6e90\u8bed\u6cd5\u53c2\u6570\u53ca\u8bf4\u660e<\/tr>\n<tbody>\n<tr>\n<td>46<\/td>\n<td>document.open()<\/td>\n<td>\u6253\u5f00\u4e00\u4e2a\u6587\u6863\u6d41\u7528\u4e8e\u5199\u5165\u3002<\/td>\n<td>&#034;open&#034;&#xff08;\u6253\u5f00&#xff09;<\/td>\n<td>document.open();<\/td>\n<td>\u65e0\u53c2\u6570\u3002\u6253\u5f00\u6587\u6863\u6d41&#xff0c;\u6e05\u9664\u5f53\u524d\u6587\u6863\u5185\u5bb9\u3002\u901a\u5e38\u5728\u8c03\u7528\u00a0document.write()\u00a0\u524d\u4f7f\u7528\u3002<\/td>\n<\/tr>\n<tr>\n<td>47<\/td>\n<td>document.close()<\/td>\n<td>\u5173\u95ed\u6587\u6863\u8f93\u51fa\u6d41\u3002<\/td>\n<td>&#034;close&#034;&#xff08;\u5173\u95ed&#xff09;<\/td>\n<td>document.close();<\/td>\n<td>\u65e0\u53c2\u6570\u3002\u5b8c\u6210\u6587\u6863\u5199\u5165\u540e\u5173\u95ed\u8f93\u51fa\u6d41&#xff0c;\u663e\u793a\u6240\u6709\u5199\u5165\u7684\u5185\u5bb9\u3002<\/td>\n<\/tr>\n<tr>\n<td>48<\/td>\n<td>document.write()<\/td>\n<td>\u5411\u6587\u6863\u5199\u5165 HTML \u8868\u8fbe\u5f0f\u6216 JavaScript \u4ee3\u7801\u3002<\/td>\n<td>&#034;write&#034;&#xff08;\u5199\u5165&#xff09;<\/td>\n<td>document.write(markup);<\/td>\n<td>markup: \u5b57\u7b26\u4e32&#xff0c;\u8981\u5199\u5165\u7684 HTML \u5185\u5bb9\u3002\u5982\u679c\u5728\u9875\u9762\u52a0\u8f7d\u5b8c\u6210\u540e\u8c03\u7528&#xff0c;\u4f1a\u8986\u76d6\u6574\u4e2a\u9875\u9762\u3002<\/td>\n<\/tr>\n<tr>\n<td>49<\/td>\n<td>document.writeln()<\/td>\n<td>\u5411\u6587\u6863\u5199\u5165 HTML \u5185\u5bb9\u5e76\u9644\u52a0\u4e00\u4e2a\u6362\u884c\u7b26\u3002<\/td>\n<td>&#034;write&#034;&#xff08;\u5199\u5165&#xff09;&#043; &#034;ln&#034;&#xff08;line&#xff0c;\u884c&#xff09;<\/td>\n<td>document.writeln(markup);<\/td>\n<td>markup: \u5b57\u7b26\u4e32&#xff0c;\u8981\u5199\u5165\u7684 HTML \u5185\u5bb9\u3002\u4e0e\u00a0write()\u00a0\u7c7b\u4f3c&#xff0c;\u4f46\u4f1a\u6dfb\u52a0\u6362\u884c\u7b26\u3002<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>\u7b2c\u4e5d\u90e8\u5206&#xff1a;\u9ad8\u7ea7\u65b9\u6cd5&#xff08;2\u4e2a&#xff09;<\/h4>\n<table>\n<tr>\u65b9\u6cd5\u542b\u4e49\u8bcd\u6e90\u8bed\u6cd5\u53c2\u6570\u53ca\u8bf4\u660e<\/tr>\n<tbody>\n<tr>\n<td>50<\/td>\n<td>document.getAnimations()<\/td>\n<td>\u8fd4\u56de\u5f53\u524d\u6587\u6863\u4e2d\u6240\u6709\u6fc0\u6d3b\u7684 Animation \u5bf9\u8c61\u7684\u6570\u7ec4\u3002<\/td>\n<td>&#034;get&#034;&#xff08;\u83b7\u53d6&#xff09;&#043; &#034;Animations&#034;&#xff08;\u52a8\u753b\u4eec&#xff09;<\/td>\n<td>let animations &#061; document.getAnimations();<\/td>\n<td>\u65e0\u53c2\u6570\u3002\u8fd4\u56de\u4e00\u4e2a\u5305\u542b\u6240\u6709\u5c1a\u672a\u81ea\u52a8\u79fb\u9664\u7684 Animation \u5bf9\u8c61\u7684\u6570\u7ec4\u3002<\/td>\n<\/tr>\n<tr>\n<td>51<\/td>\n<td>document.getBoxQuads()<\/td>\n<td>&#xff08;\u5b9e\u9a8c\u6027 API&#xff09;\u8fd4\u56de\u5143\u7d20\u5728\u6587\u6863\u4e2d\u7684 CSS \u76d2\u5b50\u56db\u8fb9\u5f62\u7684\u51e0\u4f55\u4fe1\u606f\u3002<\/td>\n<td>&#034;get&#034;&#xff08;\u83b7\u53d6&#xff09;&#043; &#034;BoxQuads&#034;&#xff08;\u76d2\u5b50\u56db\u8fb9\u5f62&#xff09;<\/td>\n<td>let quads &#061; document.getBoxQuads(options);<\/td>\n<td>options: \u53ef\u9009\u914d\u7f6e\u5bf9\u8c61\u3002\u8fd9\u662f\u4e00\u4e2a\u5b9e\u9a8c\u6027 API&#xff0c;\u4e0d\u5efa\u8bae\u5728\u751f\u4ea7\u73af\u5883\u4e2d\u4f7f\u7528\u3002<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n","protected":false},"excerpt":{"rendered":"<p>Document\u5bf9\u8c61\u7684\u65b9\u6cd5\u662fJavaScript\u64cd\u4f5cDOM\u7684\u6838\u5fc3\u624b\u6bb5&#xff0c;\u5b83\u80fd\u8ba9\u5f00\u53d1\u8005\u7cbe\u51c6\u83b7\u53d6\u3001\u521b\u5efa\u3001\u4fee\u6539\u9875\u9762\u5143\u7d20&#xff0c;\u8fd8\u80fd\u7ed1\u5b9a\u4e8b\u4ef6\u3001\u7ba1\u7406\u6837\u5f0f\u4e0e\u6587\u6863\u7ed3\u6784&#xff0c;\u662f\u5b9e\u73b0\u7f51\u9875\u52a8\u6001\u4ea4\u4e92\u3001\u5185\u5bb9\u66f4\u65b0\u4e0e\u5e03\u5c40\u8c03\u6574\u7684\u5173\u952e&#xff0c;\u652f\u6491\u7740\u524d\u7aef\u9875\u9762\u4ece\u9759\u6001\u5c55\u793a\u5230\u52a8\u6001\u4ea4\u4e92\u7684\u8f6c\u53d8&#xff0c;\u662f\u524d\u7aef\u5f00\u53d1\u4e2d\u5b9e\u73b0\u4e30\u5bcc\u7528\u6237\u4f53\u9a8c\u7684\u57fa\u7840\u5de5\u5177\u3002\u5728\u73b0\u4ee3\u524d\u7aef\u5f00\u53d1\u4e2d&#xff0c;Document\u5bf9\u8c61\u7684\u65b9\u6cd5\u4f9d\u7136\u662f\u5404\u7c7b\u6846\u67b6\u5e95\u5c42\u4ea4\u4e92\u7684\u6838\u5fc3\u4f9d\u6258&#xff0c;\u5373\u4fbf\u6846\u67b6\u5c01\u88c5\u4e86\u66f4\u4e0a\u5c42\u7684API&amp;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[8936,8938,8937,187,190],"topic":[],"class_list":{"0":"post-79879","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"hentry","6":"category-server","7":"tag-document","10":"tag-javascript","11":"tag-190"},"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>JavaScript\u4e2dDocument\u5bf9\u8c61\u5e38\u89c1\u7684\u7684\u65b9\u6cd5\u5206\u6790 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/79879.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"JavaScript\u4e2dDocument\u5bf9\u8c61\u5e38\u89c1\u7684\u7684\u65b9\u6cd5\u5206\u6790 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"Document\u5bf9\u8c61\u7684\u65b9\u6cd5\u662fJavaScript\u64cd\u4f5cDOM\u7684\u6838\u5fc3\u624b\u6bb5&#xff0c;\u5b83\u80fd\u8ba9\u5f00\u53d1\u8005\u7cbe\u51c6\u83b7\u53d6\u3001\u521b\u5efa\u3001\u4fee\u6539\u9875\u9762\u5143\u7d20&#xff0c;\u8fd8\u80fd\u7ed1\u5b9a\u4e8b\u4ef6\u3001\u7ba1\u7406\u6837\u5f0f\u4e0e\u6587\u6863\u7ed3\u6784&#xff0c;\u662f\u5b9e\u73b0\u7f51\u9875\u52a8\u6001\u4ea4\u4e92\u3001\u5185\u5bb9\u66f4\u65b0\u4e0e\u5e03\u5c40\u8c03\u6574\u7684\u5173\u952e&#xff0c;\u652f\u6491\u7740\u524d\u7aef\u9875\u9762\u4ece\u9759\u6001\u5c55\u793a\u5230\u52a8\u6001\u4ea4\u4e92\u7684\u8f6c\u53d8&#xff0c;\u662f\u524d\u7aef\u5f00\u53d1\u4e2d\u5b9e\u73b0\u4e30\u5bcc\u7528\u6237\u4f53\u9a8c\u7684\u57fa\u7840\u5de5\u5177\u3002\u5728\u73b0\u4ee3\u524d\u7aef\u5f00\u53d1\u4e2d&#xff0c;Document\u5bf9\u8c61\u7684\u65b9\u6cd5\u4f9d\u7136\u662f\u5404\u7c7b\u6846\u67b6\u5e95\u5c42\u4ea4\u4e92\u7684\u6838\u5fc3\u4f9d\u6258&#xff0c;\u5373\u4fbf\u6846\u67b6\u5c01\u88c5\u4e86\u66f4\u4e0a\u5c42\u7684API&amp;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/79879.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-03-03T07:10:46+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"28 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/79879.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/79879.html\",\"name\":\"JavaScript\u4e2dDocument\u5bf9\u8c61\u5e38\u89c1\u7684\u7684\u65b9\u6cd5\u5206\u6790 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-03-03T07:10:46+00:00\",\"dateModified\":\"2026-03-03T07:10:46+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/79879.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/79879.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/79879.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"JavaScript\u4e2dDocument\u5bf9\u8c61\u5e38\u89c1\u7684\u7684\u65b9\u6cd5\u5206\u6790\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"JavaScript\u4e2dDocument\u5bf9\u8c61\u5e38\u89c1\u7684\u7684\u65b9\u6cd5\u5206\u6790 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/79879.html","og_locale":"zh_CN","og_type":"article","og_title":"JavaScript\u4e2dDocument\u5bf9\u8c61\u5e38\u89c1\u7684\u7684\u65b9\u6cd5\u5206\u6790 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"Document\u5bf9\u8c61\u7684\u65b9\u6cd5\u662fJavaScript\u64cd\u4f5cDOM\u7684\u6838\u5fc3\u624b\u6bb5&#xff0c;\u5b83\u80fd\u8ba9\u5f00\u53d1\u8005\u7cbe\u51c6\u83b7\u53d6\u3001\u521b\u5efa\u3001\u4fee\u6539\u9875\u9762\u5143\u7d20&#xff0c;\u8fd8\u80fd\u7ed1\u5b9a\u4e8b\u4ef6\u3001\u7ba1\u7406\u6837\u5f0f\u4e0e\u6587\u6863\u7ed3\u6784&#xff0c;\u662f\u5b9e\u73b0\u7f51\u9875\u52a8\u6001\u4ea4\u4e92\u3001\u5185\u5bb9\u66f4\u65b0\u4e0e\u5e03\u5c40\u8c03\u6574\u7684\u5173\u952e&#xff0c;\u652f\u6491\u7740\u524d\u7aef\u9875\u9762\u4ece\u9759\u6001\u5c55\u793a\u5230\u52a8\u6001\u4ea4\u4e92\u7684\u8f6c\u53d8&#xff0c;\u662f\u524d\u7aef\u5f00\u53d1\u4e2d\u5b9e\u73b0\u4e30\u5bcc\u7528\u6237\u4f53\u9a8c\u7684\u57fa\u7840\u5de5\u5177\u3002\u5728\u73b0\u4ee3\u524d\u7aef\u5f00\u53d1\u4e2d&#xff0c;Document\u5bf9\u8c61\u7684\u65b9\u6cd5\u4f9d\u7136\u662f\u5404\u7c7b\u6846\u67b6\u5e95\u5c42\u4ea4\u4e92\u7684\u6838\u5fc3\u4f9d\u6258&#xff0c;\u5373\u4fbf\u6846\u67b6\u5c01\u88c5\u4e86\u66f4\u4e0a\u5c42\u7684API&amp;","og_url":"https:\/\/www.wsisp.com\/helps\/79879.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-03-03T07:10:46+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"28 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/79879.html","url":"https:\/\/www.wsisp.com\/helps\/79879.html","name":"JavaScript\u4e2dDocument\u5bf9\u8c61\u5e38\u89c1\u7684\u7684\u65b9\u6cd5\u5206\u6790 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-03-03T07:10:46+00:00","dateModified":"2026-03-03T07:10:46+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/79879.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/79879.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/79879.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"JavaScript\u4e2dDocument\u5bf9\u8c61\u5e38\u89c1\u7684\u7684\u65b9\u6cd5\u5206\u6790"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/79879","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=79879"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/79879\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=79879"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=79879"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=79879"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=79879"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}