outerHTML 에 대한 함수 지원을 몇군데 브라우저에서 지원하지 않아 아래 처럼 플러그인을 사용하면 가져올 수 있다.
출처 : http://boedesign.com/blog/2011/03/31/outerhtml-plugin-for-jquery/
/* * Full example here: http://jsfiddle.net/jboesch26/3SKsL/1/ */$.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]));}console.log('native outerHTML: ' + $('#colors')[0].outerHTML);console.log('jQuery cross-browser outerHTML: '+ $('#colors').outerHTML());
* 단축키는 한글/영문 대소문자로 이용 가능하며, 티스토리 기본 도메인에서만 동작합니다.