Skip to content

Instantly share code, notes, and snippets.

@eiriklv
Created September 28, 2014 11:11
Show Gist options
  • Save eiriklv/d87b4e0986e8887bdb5d to your computer and use it in GitHub Desktop.
Save eiriklv/d87b4e0986e8887bdb5d to your computer and use it in GitHub Desktop.
Get meta property values with jquery
function getMetaProperty($, wantedProperty) {
var meta = $('meta');
var keys = Object.keys(meta);
var metaProperty;
keys.forEach(function (key) {
if (meta[key].attributes && meta[key].attributes.property && meta[key].attributes.property.value === wantedProperty) {
metaProperty = meta[key].content;
}
});
return metaProperty || '';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment