Приставка за външен HTML jQuery - CSS-трикове

Anonim

innerHTML () е роден и връща съдържанието на DOM възел (напр I live inside a div.. externalHTML () не е, което ще включва текущия DOM възел (напр. I live inside a div. ). Това е jQuery версия с възможност за веригиране на това.

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