JSFiddle - React, Tailwind, and code Playground
by jimp
JavaScript
var html = "<html>\n"+
"<head>\n"+
" <title>See Our Events</title>\n"+
"</head>\n"+
"<body><div id=\"content\">testing</div></body>\n"+
"</html>";
document.write('<div>Source HTML:<br/>');
document.write('<div style="border: 1px solid black;">');
document.write(html.replace(/</g,'<')
.replace(/>/g,'>')
.replace(/\n/g,'<br/>\n'));
document.write('</div>');
// Create a jQuery object from the HTML.
// Look for various nodes in the document fragment.
var $content = $(html);
document.write('Test w/ source HTML:\n');
document.write('<div style="border: 1px solid black;">');
if ($content.html())
{
document.write($content.html().replace(/</g,'<')
.replace(/>/g,'>')
.replace(/\n/g,'<br/>\n'));
}
document.write('</div>');
document.write('<p>$content.length: ' + $content.length + '</p>');
document.write('<p>$(\'title\',$content).length: ' + $('title',$content).length + '</p>');
document.write('<p>$(\'head title\',$content).length: ' + $('head title',$content).length + '</p>');
document.write('<p>$content.find(\'title\').length: ' + $content.find('title').length + '</p>');
document.write('<p>$content.find(\'head\').find(\'title\').length:' + $content.find('head').find('title').length + '</p>');
// Do it again with the HTML wrapped in a <div>.
var $content = $('<div>'+html+'</div>');
document.write('Test w/ wrapped HTML:\n');
document.write('<div style="border: 1px solid black;">');
if ($content.html())
{
document.write($content.html().replace(/</g,'<')
.replace(/>/g,'>')
.replace(/\n/g,'<br/>\n'));
}
document.write('</div>');
document.write('<p>$content.length: ' + $content.length ...