我正在尝试使用Javascript
制作ul内的音乐专辑的动态列表 var heavyArtillery = new Album("Heavy Artillery","Arkasia","2011");
var antenna = new Album("Antenna","Sonic Youth","2012");
albumList = new Array(heavyArtillery,antenna);
var albumLi;
var ul = document.getElementById("albumlist");
for(var i=0; i<albumList.length; i=i+1)
{
albumLi = document.createElement('li');
albumLi.innerHTML = ""+albumList[i].album;
//ul.appendChild(albumLi);
alert(i);
}
如果我从appendChild行获取评论,则警报(i)甚至不会显示。为什么它不能正常工作?这是HTML片段:
<div data-theme="a" data-role="header">
<h3>
Albums
</h3>
</div>
<ul id="albumlist">
</ul>