DOM insertBefore() & DOM parentNode property

這兩個常一起搭配使用,

所以一起看,


insertBefore()定義:

inserts a node as a child, right before an existing child, which you specify.

另外, 很常用的一招: 當你希望在list中新增含有text node的node時,
code的做法流程為-->

If you want to create a new list item, with text, remember to create the text as a Text node which you append to the <li> element, then insert <li> to the list.

HTML DOM insertBefore() Method:
http://www.w3schools.com/jsref/met_node_insertbefore.asp


parentNode定義:

returns the parent node of the specified node, as a Node object.

HTML DOM parentNode Property:
http://www.w3schools.com/jsref/prop_node_parentnode.asp



留言

熱門文章