菜单切换
FACESOHO知行者
心灵
记录
远方
赞赏工具
源代码:
点击运行
保存
<!DOCTYPE html> <html> <body> <p>点击按钮获取 body 元素子元素的标签名。</p> <button onclick="myFunction()">点我</button> <p id="demo"></p> <script> function myFunction() { var c = document.body.children; var txt = ""; var i; for (i = 0; i < c.length; i++) { txt = txt + c[i].tagName + "<br>"; } document.getElementById("demo").innerHTML = txt; } </script> </body> </html>
运行结果