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)).html();
var body = $("body",$(htmlString)).html();
var head = $("head",htmlString).html();
var body = $("body",htmlString).html();
var head = $("head",$(htmlString).html()).html();
var body = $("body",$(htmlString).html()).html();
var head = htmlString.match(/<head[^>]*>([^<]+)<\/head>/);
var body = htmlString.match(/<body[^>]*>([^<]+)<\/body>/);
var head = jQuery('<div/>').append(htmlString).find('head').html();
var body = jQuery('<div/>').append(htmlString).find('body').html();
Any many other tries besides that. All of this return "undefined" or "" or jquery object when i try loging it to console.
Could anyone tell me how can i get the body and head tags as a string?
Prefered with jQuery/JS and not regex
$(htmlString).find("body");
?htmlString
)?htmlString
is really long but i'm not sure the browser interpets it as string could this be related?<html><head><title>foo</title><body>body</body></html>