How to get head and body tags as a string from html string?

后端 未结 5 1705
青春惊慌失措
青春惊慌失措 2021-01-15 13:22

Hey i have an html string i\'m having trouble getting the tags from.

I have tried alot of stuff, here are some :

var head = $(\"head\",$(htmlString))         


        
5条回答
  •  攒了一身酷
    2021-01-15 13:42

    Try Below Code:

    var head = htmlString.match(/]*>[\s\S]*<\/head>/gi);
    var body = htmlString.match(/]*>[\s\S]*<\/body>/gi);
    

提交回复
热议问题