如何獲取自定義meta標簽信息?


<meta name="apple-itunes-app" content="app-id=432274380" />

類似於這種meta信息,js/jquery應該如何獲取?

如果我定義了

<meta name="seg-user" content="helloworld" />

我應該如何通過js/jquery獲取?

1。

ocument.getElementsByTagName('meta')['seg-user']

2。

直接按照平常取DOM的方法來取不就好了么?不明白問題的題點在哪里誒……

document.querySelector('meta[name="seg-user"]').getAttribute('content')

 

3。

var paras = document.getElementsByTagName("meta"); var name = paras[0].getAttribute("name"); var content = paras[0].getAttribute("content"); 

假如只有一個meta標簽的笨辦法

4。

好像沒人回答jquery的版本,會稍微簡潔一點:

$('meta[name="seg-user"]');

5。
$("meta").eq(1).attr("http-equiv"), 想要什么取什么
 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM