I need to get the date from this meta on my page using javascript:
There are two dates for effective and Expires, the date I need to get is the Expires.
Is there a way to get it? I tried string methods, split but it doesn't work :/
I need to get the date from this meta on my page using javascript:
There are two dates for effective and Expires, the date I need to get is the Expires.
Is there a way to get it? I tried string methods, split but it doesn't work :/
You can get data from meta tags using querySelector
, for example author would be:
var authorTag = document.querySelector('[name=author]');
Here's a function which should do want you want for the Expires date:
function getExpires() {
var expiresTag = document.querySelector('[HTTP-EQUIV=expires]');
try {
return expiresTag.content;
} catch(e) {
console.log('Unable to get expires meta content');
return '';
}
}
var metas = document.getElementsByTagName["meta"];
and loop through finding the tag you want:
for (var i=0; i<metas.length;i++) {
if (metas[i].getAttribute("itemprop")) {
var theTagValueINeed = metas[i].getAttribute("itemprop");
}
}