What I want to achieve is to manipulate a document created using the DOM using jquery, passing a large html string. Consider the following example:
var doctype = document.implementation.createDocumentType( 'html', '', '');
var dom = document.implementation.createDocument('', 'html', doctype);
dom.documentElement.innerHTML = '<head><head><title>A title</title></head><body><div id="test">This is another div</div></body>';
This will create a new document in dom with the content provided. Now I want to use jquery to add let say div to an existing div.
$('#test',dom).append('<div> A second div</div>');
console.log(dom);
When I print the result in the console, it seems that innerHTML for "dom" has not changed. From the jQuery API documentation http://api.jquery.com/jQuery/, the more specific jQuery function (selector [, context]) "should allow this.
Since someone might argue about using the console for debugging, I provide below another piece of code that doesn't work:
$('body').append($('#test',dom));
chrome firefox, jquery.