开发者

Can i get a meta value with jQuery/JS?

Im struggling to find any information on getting meta values.

I have a locale set in the meta on a few sites and would like to use a centralised js file so i need to grab the value from say for example

<meta name="locale" id开发者_Python百科="locale" content="en_ZA" />

hmmmm....

Many thanks


var m = $("meta[name=locale]");    

alert(m.attr("content"));

Would that suffice?


Easy way with example code-

var content = $("meta[name=listing-page-url]").attr("content");
console.log(content);
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

<meta name="listing-page-url" content="demo-url" />

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜