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?
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");
console.log($(response)), you will see just[ <h1>hello</h1>], So you can use$(response).appendTo("#output");