日期:2014-05-17 浏览次数:20703 次
<html> <head></head> <script language="javascript"> var items = new Array(); function display() { var view = document.getElementById("items"); var content = ""; for (var val in items) { content = content + "<li>" + val + "</li>"; } view.innerHTML = content; } function doPop() { var val = prompt("please input item:"); items[val] = val; display(); } </script> <body> <input type="button" value="new item" onclick=doPop()> <div id="items"> </div> </body> </html>
------解决方案--------------------