17-6.html
来自「js 全的样例代码,比较适合大家学习和交流」· HTML 代码 · 共 19 行
HTML
19 行
<script>// This function takes a node n, replaces it in the tree with an Element node// that represents an html <b> tag, and then makes the original node the// child of the new <b> element.function embolden(node) { var bold = document.createElement("b"); // Create a new <b> Element var parent = node.parentNode; // Get the parent of node parent.replaceChild(bold, node); // Replace node with the <b> tag bold.appendChild(node); // Make node a child of the <b> tag}</SCRIPT><!-- A couple of sample paragraphs --><p id="p1">This <i>is</i> paragraph #1.</p><p id="p2">This <i>is</i> paragraph #2.</p><!-- A button that invokes the embolden() function on the first paragraph --><button onclick="embolden(document.getElementById('p1'));">Embolden</button>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?