我遇到了类似的问题,我的代码如下:
<!doctype html>
<html>
<title> this is a test page</title>
<meta charset="utf-8">
<head>
<script>
function test(){
var unorderedList = document.getElementById('list');
var noList = unorderedList.getElementsByTagName('li');
var number;
alert("this is a test : "+noList[0].value);
for( int i=0; i<noList.length; i++){
number = number + noList[i].value;}
console.log(number);};
window.onload=test;
</script>
</head>
<body>
<ul id="list">
<li> 2</li>
<li> 3</li>
</ul>
</body>
我无法总结“ul”中的数字,您能帮帮我吗?