英文:
Why are the bullets for the unordered list being displaying before the items were added into the list?
问题
为什么在添加列表项之前显示了子弹点?
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title>待办事项列表</title>
</head>
<body>
<h1> <%=kindOfDay%> </h1>
<ul>
<% for (var i =0; i<= newListItems.length; i++){ %>
<li> <%= newListItems[i] %></li>
<% } %>
</ul>
<form action="/" method="post">
<input type="text" name="newItem" >
<button type="submit" name="button">添加</button>
</form>
</body>
</html>
英文:
Why are the bullets being displayed before the list items were added?
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title>To Do List</title>
</head>
<body>
<h1> <%=kindOfDay%> </h1>
<ul>
<% for (var i =0; i<= newListItems.length; i++){ %>
<li> <%= newListItems[i] %></li>
<% } %>
</ul>
<form action="/" method="post">
<input type="text" name="newItem" >
<button type="submit" name="button">Add</button>
</form>
</body>
</html>
答案1
得分: 0
这是一个差一的错误,请尝试使用以下代码:
<% for (var i=0; i < newListItems.length; i++){ %>
<li> <%= newListItems[i] %></li>
<% } %>
英文:
It's an off-by-one error, try this instead:
<% for (var i=0; i < newListItems.length; i++){ %>
<li> <%= newListItems[i] %></li>
<% } %>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论