实现代码
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>exploreDOMNode</title> <style>
</style> </head> <body> <div id="myDiv"> <p>This is a Div element!</p> </div> <script> var divNode = document.getElementById('myDiv'); //输出 DIV console.info(divNode.nodeName); //输出 1 console.info(divNode.nodeType); //输出 This is a Div element! console.info(divNode.innerText); //输出 <p>This is a Div element!</p> console.info(divNode.innerHTML); </script> </body> </html>
|
页面效果
从零到现在,一路走来,感谢众多无私的知识分享者,我愿意为你们接下一棒!