【问题标题】:Jquery Select meta[property=og:image]?Jquery 选择元 [property=og:image]?
【发布时间】:2012-02-17 03:47:13
【问题描述】:

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

我想选择以下内容: 元属性="og:image" 内容="http://blablabla.jpg"

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

有什么想法吗? 谢谢

【问题讨论】:

    标签: jquery select meta facebook-opengraph


    【解决方案1】:

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

    http://jsfiddle.net/ZxmCw/

    【讨论】:

    • 这是次要的但因为你可以有多个 og:image 我添加的标签: $('meta[property="og:image"]:eq(0)').attr('content' )。 jUQery 选择器 FTW
    【解决方案2】:

    :image 被解析为伪选择器。我认为您需要在 "og:image" 周围加上引号

    【讨论】:

      猜你喜欢
      • 2015-07-13
      • 1970-01-01
      • 1970-01-01
      • 2017-11-17
      • 1970-01-01
      • 2014-11-20
      • 2019-05-21
      • 2017-08-07
      • 1970-01-01
      相关资源
      最近更新 更多