我正在尝试在 HTML 中创建一个动态列表,我正在使用字符串数组作为列表的数据,这个数组没问题,里面有一些字符串,我验证了它。所以这是我的代码:
function add_li(list, text) {
var list = document.getElementById(list);
var li = document.createElement("li");
li.innerHTML = text;
list.appendChild(li);
}
function load_list(list, list_array) {
for (var i = 0; i < list_array.length; i++) {
add_li (list, list_array[i]);
}
}
这是电话:
load_list(lista_bodegas, Bodegas);
html在哪里:
<html>
<head>
<link rel="stylesheet" type="text/css" href="../../css/main.css">
<script type="text/javascript" src="../../js/main.js"></script>
<script type="text/javascript" src="../../js/cordova-2.3.0.js"></script>
<meta name="viewport" id="viewport" content="width=device-width, height=device-height, minimum-scale=1, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<title>
</title>
</head>
<body onload= "cargarBodegas();">
<ul id= "lista_bodegas">
</ul>
</body>
</html>