17-3.html

来自「js 全的样例代码,比较适合大家学习和交流」· HTML 代码 · 共 19 行

HTML
19
字号
<head><title>Reverse</title></head><script>function reverse(n) {          // Reverse the order of the children of Node n    var kids = n.childNodes;   // Get the list of children    var numkids = kids.length; // Figure out how many there are    for(var i = numkids-1; i >= 0; i--) {  // Loop through them backwards        var c = n.removeChild(kids[i]);    // Remove a child        n.appendChild(c);                  // Put it back at its new position    }}</script></head><body><p>paragraph #1<p>paragraph #2<p>paragraph #3  <!-- A sample document --><p>                                    <!-- A button to call reverse()--><button onclick="reverse(document.body);">Click Me to Reverse</button></body>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?