Jquery Select meta[property=og:image]?

和自甴很熟 提交于 2019-12-03 06:32:33

问题


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


回答1:


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

http://jsfiddle.net/ZxmCw/




回答2:


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



来源:https://stackoverflow.com/questions/8977652/jquery-select-metaproperty-ogimage

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!