In jQuery you can do this:
$("meta[property='fb:app_id']").attr("content");
Which will give you the content
attribute value from the meta
-tag with property
attribute "fb:app_id".
How can I do this in plain ol' Javascript?
Thank you in advance. :-)
Kenneth
Not as elegant as JQuery I'm afraid...
var metaTags=document.getElementsByTagName("meta");
var fbAppIdContent = "";
for (var i = 0; i < metaTags.length; i++) {
if (metaTags[i].getAttribute("property") == "fb:app_id") {
fbAppIdContent = metaTags[i].getAttribute("content");
break;
}
}
console.log(fbAppIdContent);
document.querySelector('meta[property~="fb:app_id"][content]').content
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With