fmpq.com
源代码:
点击运行
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Fmpq教程(fmpq.com)</title> </head> <body> <p id="demo">点击一个按钮来添加文本,点击另一个按钮规范化文档</p> <button onclick="addTextNode()">添加一个文本节点</button> <button onclick="normPara()">规范文本</button> <script> function addTextNode(){ var y=document.createTextNode(" Click again"); var x=document.getElementById("demo"); x.appendChild(y); var z=document.getElementById("cc"); z.innerHTML=x.childNodes.length; } function normPara(){ document.normalize(); var x=document.getElementById("demo"); var z=document.getElementById("cc"); z.innerHTML=x.childNodes.length; } </script> <p>上面的段落有 <span id="cc">1</span>个子节点。</p> </body> </html>
运行结果