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))
Since you have well formed HTML, you can create a document and select nodes from it:
var doc = (new DOMParser()).parseFromString(htmlstring,"text/html");
console.log(doc.head.outerHTML);
console.log(doc.body.outerHTML);
Here is a demonstration: http://jsfiddle.net/X3Uq2/
In Chrome, you can't use a "text/html" content type, so you have to make an XML document and use getElementsByTagName:
var s = new XMLSerializer();
var doc = (new DOMParser()).parseFromString(data,"text/xml");
console.log(s.serializeToString(doc.getElementsByTagName("head")[0]));
console.log(s.serializeToString(doc.getElementsByTagName("body")[0]));
http://jsfiddle.net/X3Uq2/2/