我需要的信息在meta标签中。"content"何时可以访问meta标签的数据property="video"?
"content"
property="video"
HTML:
<meta property="video" content="http://video.com/video33353.mp4" />
您可以使用此:
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'));