問題出在哪兒?
?var oldnode=document.getElementById("oldnode");?????????
??????????? var newnode=document.createElement("i");?? ??? ??
?? ??? ? ? oldnode.parentNode.replaceChild(newnode,oldnode);光這幾行代碼為什么不能替換節(jié)點b?
?var oldnode=document.getElementById("oldnode");?????????
??????????? var newnode=document.createElement("i");?? ??? ??
?? ??? ? ? oldnode.parentNode.replaceChild(newnode,oldnode);光這幾行代碼為什么不能替換節(jié)點b?
2014-11-29
舉報
2014-12-23
注意:?
1.?當(dāng) oldnode 被替換時,所有與之相關(guān)的屬性內(nèi)容都將被移除。?
2. newnode 必須先被建立。
2014-11-30
是的,可以實現(xiàn),只不過沒有內(nèi)容!還要加內(nèi)容才可以看到效果!
2014-11-29
可實現(xiàn)的,但是需要等 oldNode節(jié)點加載完成后,試著把javascript 放在節(jié)點后面執(zhí)行
2014-11-29
這是在用newnode替換oldnode的父節(jié)點,另外命名用駝峰式,比如newNode