javascript document.creat Dockmentについて()
3486 ワード
彼は以下のDOM 2方法をサポートしています.
apendChild、clone Node、has Attributes、has Child Nodes、insertBefore、normalize、removeChild、replace Child.
以下のDOM 2�儺にも対応しています.
atributes、childNodes、first Child、lastChild、local Name、namespaceURI、nextSibling、nodeName、nodeType、nodeValue、ownetNode、prefix、previous Sibling、textContint.
他の方法は、ドキュメント・フラジャイムがコツコツとして働いても良いです.(例えば、NodeのapendChildとinsertBeforeの方法)、�@は桜、fragmentが父に追加されます.ο笾小�
Example:
ページの最適化のために、できるだけDOMの操作を減らし、リスト項目をテキストノードを追加した後、追加し、合理的にcreat DockMentFragment()を使用します.コードは以下の通りです.
---------------------------
DcumentFragment is a「lightweight」or「minimal」Dcument object.It is very common to want to be able to extract a port of a document's tree or to create a new fragment of a document.Imagine implement a user command like cut or rearrarararand a document by moving frome frontrament.Imantables.rament.purpose.While it is true that a Document oject could fulfill this role,a Dock oject can potenttiallybe a heavyweight oject,depending on the undering implement.What reit allyneed for overis
Frerthere more、various operations--such as inserting nodes as children of another Node--may take DockMentFragment oject as argments;this reults in all the child nodes of the DockMentFragment being moved to the child list of this node.
The children of a DocumentFragment node rererepresenting the tops of any sub-trees defining the stststststucture of the document.DcumentFragment nodes nodet need to be well-formed XML documetttttttttttttttttttttttts(althththethethethethethethethethethethethethethethethetherererererererererererereeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeettttttttttttttttttFor example、a DcumentFragment might have only one child and that child node could be a Text node.Such a structure model represents neither an HTML document nor a well-formed XML document.
When a DcumentFragment is inserted into a Dockment(or indeed any other Node that may tate children)the children of the Docment Fragment and not the DcumentFrament t the the Node.This makers the Freture.the DcumentFragment acts the parent of the se nodes so that the user can use the standard methods from the Node interface,such as insertBefore and apped.
apendChild、clone Node、has Attributes、has Child Nodes、insertBefore、normalize、removeChild、replace Child.
以下のDOM 2�儺にも対応しています.
atributes、childNodes、first Child、lastChild、local Name、namespaceURI、nextSibling、nodeName、nodeType、nodeValue、ownetNode、prefix、previous Sibling、textContint.
他の方法は、ドキュメント・フラジャイムがコツコツとして働いても良いです.(例えば、NodeのapendChildとinsertBeforeの方法)、�@は桜、fragmentが父に追加されます.ο笾小�
Example:
var frag = document.createDocumentFragment();
frag.appendChild(document.createTextNode('Ipsum Lorem'));
document.body.appendChild(frag);
ドcument.create DocktFragmentははっきり言って、DOMを節約するために使います.毎回JavaScriptはDOMの操作に対してページの換金を変えて、そして全体のページを更新して、それによって大量の時間を消耗しました.この問題を解決するために、ドキュメントの破片を作成し、すべての新しいノードを追加して、ドキュメントの破片の内容を一度にdocumentに追加します.
var oui=document.getElementById("oItem");
for(var i=0;i<10;i++)
{
var oli=document.createElement("li");
oui.appendChild(oli);
oli.appendChild(document.createTextNode("Item"+i));
}
上のコードは循環中にOni.apped Child(oli)を呼び出しています.この文を実行するたびにブラウザはページを更新します.次に下のoui.apendChild()はテキストノードを追加して、ページを更新します.だから全部で20回ページを更新します.ページの最適化のために、できるだけDOMの操作を減らし、リスト項目をテキストノードを追加した後、追加し、合理的にcreat DockMentFragment()を使用します.コードは以下の通りです.
var oui=document.getElementById("oItem");
var oFragment=document.createDocumentFragment();
for(var i=0;i<10;i++){
var oli=document.createElement("li");
oli.appendChild(document.createTextNode("Item"+i));
oFragment.appendChild(oli);
}
oui.appendChild(oFragment);
W 3 C参考:http://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-B 63 ED 1 A 3---------------------------
DcumentFragment is a「lightweight」or「minimal」Dcument object.It is very common to want to be able to extract a port of a document's tree or to create a new fragment of a document.Imagine implement a user command like cut or rearrarararand a document by moving frome frontrament.Imantables.rament.purpose.While it is true that a Document oject could fulfill this role,a Dock oject can potenttiallybe a heavyweight oject,depending on the undering implement.What reit allyneed for overis
Frerthere more、various operations--such as inserting nodes as children of another Node--may take DockMentFragment oject as argments;this reults in all the child nodes of the DockMentFragment being moved to the child list of this node.
The children of a DocumentFragment node rererepresenting the tops of any sub-trees defining the stststststucture of the document.DcumentFragment nodes nodet need to be well-formed XML documetttttttttttttttttttttttts(althththethethethethethethethethethethethethethethethetherererererererererererereeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeettttttttttttttttttFor example、a DcumentFragment might have only one child and that child node could be a Text node.Such a structure model represents neither an HTML document nor a well-formed XML document.
When a DcumentFragment is inserted into a Dockment(or indeed any other Node that may tate children)the children of the Docment Fragment and not the DcumentFrament t the the Node.This makers the Freture.the DcumentFragment acts the parent of the se nodes so that the user can use the standard methods from the Node interface,such as insertBefore and apped.