簡體   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