Find each div with the specified class
var data='<div class="shout_msg"> <span class="username">3</span> <span class="message">hello</span> </div> <div class="shout_msg"> <span class="username">0</span> <span class="message">yo</span> </div> <div class="shout_msg"> <span class="username">0</span> <span class="message">hey</span> </div> <div class="shout_msg"> <span class="username">0</span> <span class="message">haha</span> </div>'; $(data).find(".shout_msg").each(function(index){ console.log($(this).find("span.username").text() ); }); It does not return anything. Basically, the data shown here in the variable comes from an AJAX request. But in any case, I am making a stupid mistake or something like that. Please correct me.
+4
2 answers