→、
Document の最初の子の前に、指定の Node オブジェクトまたは文字列オブジェクトを挿入します。
String オブジェクトは、同等の Text ノードとして挿入されます。
このメソッドは、子を Document の先頭に追加します。ツリー内の任意の要素の先頭に追加するには、Element.prepend() を参照してください。
挿入する Node または文字列オブジェクトのセット。 |
なし(undefined)。
Doc=new Document(); //ドキュメント オブジェクト生成。 S=String("てすと"); //文字列生成。 Doc.prepend(S); //生成した Doc オブジェクトに文字列オブジェクト挿入。 //エラー発生:Failed to execute 'prepend' on 'Document': Nodes of type '#text' may not be inserted inside nodes of type '#document'. //'Document' で 'prepend' を実行できませんでした: タイプ '#text' のノードは、タイプ '#document' のノード内に挿入できない場合があります。
Doc=new Document(); //ドキュメント オブジェクト生成。 H=document.createElement("HTML"); //<HTML> 要素生成。 Doc.prepend(H); //生成したドキュメントに生成した<HTML> 要素を挿入。 D=Doc.children; //Docの子要素のコレクションを取得。
↑これは成功している。
Doc=new Document(); //ドキュメント オブジェクト生成。 B=document.createElement("BODY"); //<BODY> 要素生成。 Doc.prepend(B); //生成したドキュメントに生成した<BODY> 要素を挿入。 D=Doc.children; //Docの子要素のコレクションを取得。 //=[object]:[object HTMLCollection] //0=[object]:[object HTMLBodyElement] //length=[number]:1 //item=[function]:function item() { [native code] } //namedItem=[function]:function namedItem() { [native code] } DA=D[0].tagName; //=[string]:body Head=document.createElement("Head"); //HEAD要素を生成。 Doc.prepend(Head); //Docの子要素の前にHEADを挿入。 //エラー発生:Failed to execute 'prepend' on 'Document': Only one element on document allowed. //'Document' で 'prepend' を実行できませんでした: ドキュメントで許可される要素は 1 つだけです。
¶意味なし。