I am trying to parse this html through jQuery to get data1, data2, data3. While I do get data2 and data3 I am unable to get data3 with my approach. I am fairly new to jQuery
Try this
alert($(datahtml).find(".class0 h4").text());
The reason being the text you are referring to is inside h4 element of class0 .. So your selector will not work,,
Or access the contents directly..
alert($(".class0 h4").text());
alert($(".class1").text());
alert($("#mydivid").text());
EDIT
var datahtml = "data1
data2
data3
";
$('body').html(datahtml);
alert($(".class0 h4").text());
alert($(".class1").text());
alert($("#mydivid").text());
CHECK DEMO