為什么我通過createElement方法添加的空P元素不能通過firstChild.nodeValue改變文本內容,而用html寫的空P元素可以??//動態添加空的p元素?? ? ? var addtext = document.createElement('p');? ? ? ? addtext.id = "description";? ? ? ? document.getElementsByTagName('body')[0].appendChild(addtext);//改變文本內容? ? ? var description = document.getElementById('description');? ? ? var text = whichpic.getAttribute('title');? ? ? description.firstChild.nodeValue=text;
關于js動態創建HTML內容的問題,麻煩大家幫忙看看
和光
2016-04-26 10:52:55