Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我需要显示文档中所有元标记的名称属性。
我尝试使用:
var attrs = document.getElementsByTagName("meta").attributes;
但它不起作用。
您可以尝试一个简单的for循环:
for
var metas = document.getElementsByTagName("meta") var names = [] for (var i = 0; i < metas.length; i ++) { names.push(metas[i].name) }