jqueryselectfacebook-opengraphhtml-meta

How to select a meta tag with a specific og: property in jQuery


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?


Solution

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

    http://jsfiddle.net/ZxmCw/