0
조각은 그 조각으로 몸의 모든 컨텐츠를 추가 작성하는 것입니다 내가 자바 스크립트 (더 라이브러리)을하지 않는다 시도하고있다 :임시 컨테이너를 생성하고 해당 컨테이너에 모든 본문 내용을 추가
var _fragment = document.createDocumentFragment(),
_children = document.body.childNodes;
for(var i=0,_clen=_children.length; i<_clen; i++) {
_fragment.appendChild(_children[i]);
}
이것은 어떤 이유로 작동하지 않는 것 같습니다.
보다도, 빠른
------------- 편집 --------------
나는 확인하기 위해 검사를 추가 노드가 정의되어 있지 않고 동작하고있는 경우.
for(var i=0,_clen=_children.length; i<_clen; i++) {
if(_children[i] !== undefined) {
_fragment.appendChild(_children[i]);
}
}
답장을 보내 주셔서 감사합니다! 어떤 방법으로
var body = document.querySelector("body");
var bodyContent = body.innerHTML;
var newElement = document.createElement("DIV");
newElement.innerHTML = bodyContent;
// adding the new element to the body
body.appendChild(newElement);
데모 http://jsfiddle.net/krasimir/Dh3Q3/
가 작동하지 않습니다 : 무엇 이것에 대해 –
NotFoundError : 노드가 존재하지 않는 컨텍스트에서 노드를 참조하려고했습니다. – Speedy