Is it possible to use a jQuery selector on an HTML string? I'm trying to get the html contents of the div, foo.
var code = "<div id='foo'>1</div><div id='bar'>2</div>";
alert( $(code).html( ) ); // returns 1 (not sure how...)
How can I get the html contents of foo and of bar in two different statements?
var code = $("<div id='foo'>1</div><div id='bar'>2</div>");
code.each(function() {
alert( $(this).html() );
})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With