JQuery select body element from string


I have a string <html><head></head><body>test</body></html> and I'm trying to get just the contents of the body using jQuery.

Ive tried


but that doesn't work.

Any ideas on how to do it?


In case it wasn't clear, I need to get the body element from a string, not the DOM.

Edit 2:

Be aware that the method used needs to not return anything form the head element. Such as inline styles.

Best Solution

var x = '<html><head></head><body>test</body></html>';
x = x.split("<body")[1].split(">").slice(1).join(">").split("</body>")[0];

Check working example at http://jsfiddle.net/6hPHn/1/