I'm trying to create some dynamic html through jquery, filter it to the part I'm interested in, and append that section of html to an existing element on the page but its not working. What am I doing wrong in this fiddle?
http://jsfiddle.net/3zKeL/4/
HTML:
<div id="output">This is the output:<br></div>
jQ:
var response = "<html><body><h1>hello</h1></body></html>";
$(response).filter("body").appendTo("#output");
$(response)
.filter(function() {
return $("body");
})
.appendTo("#output");
DEMO
You can do also
$('<div/>') // add response to fake div
.append(response)
.find('body') // find your target
.appendTo('#output'); // append the target
DEMO
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