繁体   English   中英

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

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

像这样:

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

更好的是, by Name获取meta元素

尝试这个:

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

暂无
暂无

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM