I want to parse home HTML like the following using jQuery. When I'm using document it is working. But not working when using string.
Output: null
var str = "<html><title>This is Title</title><body><p>This is a content</p><p class='test'>Test content</p></body></html>";
$str = $(document); // working
$str = $(str); // not working
alert($str.find(".test").html());
Another method (also fails):
Output: null
var str = "<html><title>This is Title</title><body><p>This is a content</p><p class='test'>Test content</p></body></html>";
alert($('.test',str).html());
The string I'm getting also cannot be parsed as XML as it is not a valid XHTML.