javascript get meta with name code example
Example 1: get meta tag value from url javascript
document.getElementsByTagName("meta").generator.getAttribute('version');
Example 2: js get meta-tag name
function getMeta(metaName) {
const metas = document.getElementsByTagName('meta');
for (let i = 0; i < metas.length; i++) {
if (metas[i].getAttribute('name') === metaName) {
return metas[i].getAttribute('content');
}
}
return '';
}
console.log(getMeta('video'));