Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何获取<head>当前页面的内容
<head>
您可以像这样使用 javascript DOM API:
var headContent = document.getElementsByTagName('head')[0].innerHTML;
您可以使用元素选择器来获取<head>,例如:
$("head") //for example: alert($("head").html()); //alerts the <head> children
你可以在这里试一试
简单来说:
document.head
// 返回对象 DOM 对象
document.head.innerHTML
// 返回文本,例如:'<title>页面标题...'