Onclick convert html to view source
by aaronk85
HTML
<p>See code</p>
<div id="test">
<p>there is lots of html code in here.</p>
</div>
CSS
#code {height: 300px; width: 300px;}
JavaScript
jQuery("#test").on('click', function () {
$('body').append('<textarea id="code"></textarea>');
var htmlStr = jQuery(this).html();
jQuery('#code').text(htmlStr);
jQuery('#code').select();
$('#test').remove();
});
jQuery("#code").on('click', function () {
$(this).select();
});