Jquery 选择元[property=og:image]?

发布于 2024-12-28 11:09:38 字数 226 浏览 4 评论 0原文

我想在 Jquery 中选择网页中的主照片,我只有 url 页面。 所以我决定使用为 Facebook 共享编写的元。

我想选择的内容: meta property="og:image" content="http://blablabla.jpg"

我写了这个,但它不起作用: $("meta[property=og:image]").attr("内容");

有什么想法吗? 谢谢

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.

I want to select the content of :
meta property="og:image" content="http://blablabla.jpg"

I wrote this, but it doesn't work:
$("meta[property=og:image]").attr("content");

Any ideas ?
Thank you

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

淡莣 2025-01-04 11:09:38

$('meta[property="og:image"]').attr('content')

http:// jsfiddle.net/ZxmCw/

$('meta[property="og:image"]').attr('content')

http://jsfiddle.net/ZxmCw/

清引 2025-01-04 11:09:38

:image 被解析为伪选择器。我认为你需要围绕“og:image”引用

:image is parsed as a pseudo-selector. I think you need quotes around "og:image"

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文