Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
$.fn.outerHTML method
* Full example here:
$.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 || (
var div = document.createElement('div');
var contents = div.innerHTML;
div = null;
return contents;
console.log('native outerHTML: ' + $('#colors')[0].outerHTML);
console.log('jQuery cross-browser outerHTML: '+ $('#colors').outerHTML());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.