Jquery 选择元[property=og:image]?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8977652/
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
Jquery Select meta[property=og:image]?
提问by Maxxx
I want to select in Jquery the main photo in a web page, I just have the url page. so I decided to use the meta written for Facebook sharing.
我想在 Jquery 中选择网页中的主照片,我只有 url 页面。所以我决定使用为 Facebook 共享编写的元数据。
I want to select the content of : meta property="og:image" content="http://blablabla.jpg"
我想选择的内容:meta property="og:image" content="http://blablabla.jpg"
I wrote this, but it doesn't work: $("meta[property=og:image]").attr("content");
我写了这个,但它不起作用: $("meta[property=og:image]").attr("content");
Any ideas ? Thank you
有任何想法吗 ?谢谢
回答by AlienWebguy
$('meta[property="og:image"]').attr('content')
$('meta[property="og:image"]').attr('content')
回答by Savageman
:image
is parsed as a pseudo-selector. I think you need quotes around "og:image"
:image
被解析为伪选择器。我认为你需要在 "og:image" 周围引用