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

前端 未结 3 937
无人及你
无人及你 2020-12-15 15:11

how to get content of the current page

相关标签:
3条回答
  • 2020-12-15 15:49

    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

    0 讨论(0)
  • 2020-12-15 15:57

    You could use the javascript DOM API like this:

    var headContent = document.getElementsByTagName('head')[0].innerHTML;
    
    0 讨论(0)
  • 2020-12-15 16:10

    Simply as:

    document.head

    // returns object DOM Object

    document.head.innerHTML

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

    0 讨论(0)
提交回复
热议问题