I am returning JSON inside an ajax request which has html as one of its values.
html:
"<div id="foo">
<p>FOO</p>
</div>
<div id="bar">
<p>BAR</p>
</div>"
I would like to add #foo to one element and #bar to another. I have tried the following:
$('#add-foo-html-here').html($(response.html).find('#foo'));
but this fails to find #foo. What is the best way to do this? Should I be adding the html content to a temp element and then finding the id?
#this(does seem strange)? If the HTML is valid (there are some quoting issues above), it should work! Also, if they don't have a parent, you can't find() them, you'd need to append to them to an empty parent first.