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.
The Facebook scraper doesn't execute JavaScript.
So using Javascript to modify the metatags in order to show different share content won't work.
You'd need to use serverside code to write them out as needed in the HTML source.
It is definitely possible to change meta tags using jQuery, but I don't think that's going to accomplish what you want since the meta tags are pulled by the FB scraper. The FB scraper goes out and scrapes your page to read the meta tags.
https://developers.facebook.com/docs/opengraph/
This is how it worked for me:
note the double backslash, without it Jquery will fail with an error.