简体   繁体   English

在JS中获取元元素的属性值的最佳方法是什么?

[英]What is the best way to get a Meta Element's Attribute Value in JS?

Something like this: 像这样:

this.token = document.getElementById("token").getAttribute("content");

Even better, get the meta element by Name 更好的是, by Name获取meta元素

尝试这个:

document.querySelector('meta[name="name"]').getAttribute("content");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在javascript对象中,获取值属性的最佳方法是什么? - in a javascript object, what's best way to get the attribute of a value? 在JS中获取元素标记名称的最佳方法是什么? - What is the best way to get an element's tag name in JS? 如何在fabric.js中获取目标元素的属性值 - How to get targeted element's attribute value in fabric.js 获取 JSON 字符串值的最佳方法是什么? - What's the best way to get a value of a JSON string? 通过值是对象(JSON)的数据属性访问元素的最佳方法是什么? - What is the best way to access an element through a data-attribute whose value is an object (JSON)? 测试DOM中元素的最佳方法是什么 - What's the best way to test an element in the DOM 在JQuery中,将一组节点的数据属性放入数组的最佳方法是什么? - In JQuery, what's the best way to get a data attribute of a set of nodes into an array? 在Angular JS 1.x中动态更改输入数字元素的验证模式的最佳方法是什么? - What's the best way of dynamically change validation pattern of an input number element in Angular JS 1.x? 检查值是时间戳的最佳方法是什么? - What's the best way of checking that a value is a timestamp? 获得用户所在城市的最佳方法是什么? - What is the best way to get a user's city?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM