Here, I attempt to make a new document with JS:
objDoc.open();
objDoc.write( "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">" );
objDoc.write( "<html>" );
objDoc.write( "<body>" );
objDoc.write( "<head>" );
objDoc.write( "<title>" );
objDoc.write( document.title );
objDoc.write( "</title>" );
objDoc.write( jStyleDiv.html() );
objDoc.write( "</head>" );
objDoc.write( this.html() );
objDoc.write( "</body>" );
objDoc.write( "</html>" );
objDoc.close();
Before I close the document (and probably after I write the html of another document I have in memory to the body of the new document), I would like to remove any elements that match a certain class and/or ID. jQuery solutions are OK. Is there a way to do this?
Thanks!
The solution AresAvatar is suggesting is correct with one addition that solves the problem that you mention: The jQuery command to execute is
the second parameter to the jQuery is the context in which the command is executed. This way it is not applied in the entire page! See the URL below from the docs of jQuery.
api.jquery.com/jQuery/
Pan