Created
September 28, 2014 11:11
-
-
Save eiriklv/d87b4e0986e8887bdb5d to your computer and use it in GitHub Desktop.
Get meta property values with jquery
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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