日期:2014-05-16  浏览次数:20396 次

通过js innerHtml动态生成div内容请帮忙、
请帮忙。

<html>
<head>
<script>
function Test(){
var aa = document.getElementById('divID');
aa.innerHtml = "<ul><li>fdasfafas</li><ul>";
aa.innerHtml += "<ul><li>erwerwer</li><ul>";
aa.innerHtml += "<ul><li>rwerwerwerw</li><ul>";
}
</script>
</head>
<body onLoad="Test()">
<div id="divID">
</div>
</body>
</html>


请帮忙看看为何不能动态生成。十分感谢。

------解决方案--------------------
HTML code


<html> 
<head> 
<script> 
function Test(){ 
alert('dd');
   var aa = document.getElementById('divID'); 
   aa.innerHTML = " <ul> <li>fdasfafas </li> <ul>"; 
           aa.innerHTML += " <ul> <li>erwerwer </li> <ul>"; 
           aa.innerHTML += " <ul> <li>rwerwerwerw </li> <ul>"; 
} 
</script> 
</head> 
<body onLoad="Test()"> 
<div id="divID"> 
</div> 
</body> 
</html>