요소의 outerHTML 가져오기

579 단어 html
항목에서 발견한 요소를 가져오는 outerHTML 방법 보기
$.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]));
    
};

좋은 웹페이지 즐겨찾기