Javascript 我可以使用 jQuery/JS 获取元值吗?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3289302/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-23 04:03:13  来源:igfitidea点击:

Can i get a meta value with jQuery/JS?

javascriptjquerymetadata

提问by c14kaa

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

我在几个站点的元数据中设置了一个语言环境,并且想使用一个集中的 js 文件,所以我需要从 say 中获取值

<meta name="locale" id="locale" content="en_ZA" />

hmmmm....

嗯……

Many thanks

非常感谢

回答by Malabar Front

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

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

Would that suffice?

这样就够了吗?