fmpq.com
源代码:
点击运行
<!DOCTYPE html> <html> <body> <head> <meta name="description" content="编程技术入门教程"> <meta name="keywords" content="HTML5,CSS,JavaScript"> <meta name="author" content="runoob"> </head> <p>点击按钮返回所有 meta 元素的name属性的值。</p> <button onclick="myFunction()">点我</button> <p id="demo"></p> <script> function myFunction() { var x = document.getElementsByTagName("META"); var txt = ""; var i; for (i = 0; i <x.length; i++) { txt = txt + "第 "+(i+1)+" 个 meta 标签 name 属性值 : "+x[i].name+"<br>"; } document.getElementById("demo").innerHTML = txt; } </script> </body> </html>
运行结果