Jquery – Changing Facebook meta tag Content Attribute using JQuery

facebookfacebook-likejquerymeta-tags

I want to know how can I use JQuery in order to replace the content attribute of my Facebook meta tags.

I searched StackOverflow and what I've found was this example:

$("meta[property=og:title]").attr("content", title);
$("meta[property=og:url]").attr("content", url);

In my code I have the following meta tags:

<meta property="og:title" content="some content"/>
<meta property="og:url" content="some content"/>
<meta property="og:site_name" content="some content"/>

When I run the function that should change the content for the 'title' and 'url' variables, the change doesn't take place. The same values for the 'content' still remains the same.

I want to know how, if it's possible, to use JQuery to change the value of Facebook's meta tags.

Best Answer

This is how it worked for me:

$('meta[name=og\\:url]').attr('content', newVideoUrl);

note the double backslash, without it Jquery will fail with an error.