आउटरएचटीएमएल jQuery प्लगइन - सीएसएस-ट्रिक्स

Anonim

भीतरी HTML () मूल है और एक DOM नोड की सामग्री लौटाता है (जैसे I live inside a div.। बाहरी HTML) नहीं है, जिसमें वर्तमान 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))); )