how to get <head> content of the current page with jquery or JS

╄→尐↘猪︶ㄣ 提交于 2020-06-07 18:19:19

问题


how to get <head> content of the current page


回答1:


You could use the javascript DOM API like this:

var headContent = document.getElementsByTagName('head')[0].innerHTML;



回答2:


You can use an element selector to get <head>, for example:

$("head")
//for example:
alert($("head").html()); //alerts the <head> children

You can give it a try here




回答3:


Simply as:

document.head

// returns object DOM Object

document.head.innerHTML

// returns text, like: '<title>Title of the page...'



来源:https://stackoverflow.com/questions/3592475/how-to-get-head-content-of-the-current-page-with-jquery-or-js

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!