Plugin jQuery esternoHTML - Trucchi CSS

Anonim

innerHTML () è nativo e restituisce il contenuto di un nodo DOM (es I live inside a div.. outerHTML () non lo è, il che includerebbe il nodo DOM corrente (es I live inside a div. .) Questa è una versione jQuery concatenabile per farlo.

$.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))); )