Output jQuery object as HTML
3 answers
If you need to print an object in HTML format, use this outerHTML or outerHTML extension .
Update
Update link and include code for second link:
$.fn.outerHTML = function(){
// IE, Chrome & Safari will comply with the non-standard outerHTML, all others (FF) will have a fall-back for cloning
return (!this.length) ? this : (this[0].outerHTML || (
function(el){
var div = document.createElement('div');
div.appendChild(el.cloneNode(true));
var contents = div.innerHTML;
div = null;
return contents;
})(this[0]));
}
+6
source to share