简单教程
提交运行
代码编辑器:
<meta name="description" content="编程技术入门教程"> <meta name="keywords" content="HTML5,CSS,JavaScript"> <meta name="author" content="Twle"> <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>
运行结果: