innerHTML () är inbyggt och returnerar innehållet i en DOM-nod (t.ex. I live inside a div.
yttre HTML () är inte, vilket skulle inkludera den aktuella DOM-noden (t.ex. I live inside a div.
). Detta är en kedjeaktig jQuery-version av att göra det.
$.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))); )