I have a text box with the following content (innerHTML):
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title></title> </head> <body> </body> </html>
To prepare the content for parsing the DOM using jQuery, I do the following (temp is just a div):
$('#temp').append(input.val()); console.log($('#temp').html());
As indicated in the jQuery object from the full HTML document , the head, body, html and doctype tags are missing:
<meta charset="utf-8"> <title></title>
So is there any other way not to add to the DOM and still get the DOM elements to work? An iframe might be a last resort, but that would be ugly.
source share