I am using a JQuery function to retrieve a string containing some HTML code and process it locally. The string is:
var return_data = '<div><tr><td>blah</td><td>more blah</td></tr><tr><td>blah</td><td>more blah</td></tr><tr><td>blah</td><td>more blah</td></tr><span id="morerows">1</span></div>';
(I understand <tr> should come inside <table> and not inside <div> but this is how I need the input for some reason and that should be inconsequential to the issue at hand.)
What I need is to loop through each <tr> and output the contents to the console. I am trying this:
$(return_data).find("tr").each(function(){
var myData = $(this).html();
console.log(myData);
});
But the above does nothing; no output on the console. Just to be sure, I changed the console.log() input to simply "hello" and turns out, the control isn't even entering the loop. What could possibly be causing this?
console.log($(this))if the loop isn't being entered to begin with. That's what I said in the question as well. Even aconsole.log("hello")didn't execute.trs are ignored because they make no sense in a div.console.log($(return_data));shows that there is only text and the span in there.