JSFiddle - React, Tailwind, and code Playground
by supertrue
HTML
<a href="#" onclick="getHTML('http://fiddle.jshell.net/');">Get and manipulate HTML</a>
JavaScript
var getHTML = function ( url ){
$.ajax({
url: url,
dataType: "html",
success: function( myHTML ) {
// view the returned HTML
alert('Successfully grabbed this HTML: \n\n' + myHTML);
// the opening <html> tag is missing (no idea why)
myHTML.replace('<head>', '<html><head>');
// put it in a jQuery wrapper
var $myHTML = $(myHTML);
// use jQuery to manipulate it
// $myHTML.find('script').remove(); // just an example
// then view the final html
alert('$myHTML.html(): \n\n' + $myHTML.html()); // doesn't work!
// that didn't work; try getting outerHTML
$myHTML = $('<div></div>').append(myHTML);
alert('$myHTML.html(): \n\n' + $myHTML.html()); // highly incomplete -- missing scripts and <head>, <body> wrappers
}
});
}