Answers for "js get meta-tag name"

2

get meta tag value from url javascript

document.getElementsByTagName("meta").generator.getAttribute('version');
Posted by: Guest on December-23-2020
0

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'));
Posted by: Guest on April-23-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language