使用此代碼DOM錯誤使用JavaScript附加
var html='<div class="somediv"></div>';
var target=document.getElementById('contentArea');
target.appendChild(html);
我越來越
Uncaught Error: NOT_FOUND_ERR: DOM Exception 8
Uncaught TypeError: Cannot call method 'appendChild' of null
什麼建議嗎?
這聽起來並不令人興奮。試試:'null.appendChild(「foo」)',注意錯誤信息,並向後工作。 – 2012-03-31 02:32:44