I have a variable that contains several HTML nodes that have the same classes. I would like to cycle through each of them, and am wondering how I would do it.
I have tried the following, but nothing happened (console did not print out anything).
var myVar = "<div class='item'>Item01</div>" +
"<div class='item'>Item02</div>" +
"<div class='item'>Item03</div>";
$(myVar).find('.item').each( function() {
console.log( $(this) ); //console does not output anything
}
$(myVar).find('.item')will not contain anything.What you need to do is:
Or just: