简体   繁体   English

添加新的待办事项列表项

[英]ADD NEW TODO LIST ITem

The goal is to create a new todo list when NEW TODO button is clicked the below is my starter script can anybody help me out?目标是在单击 NEW TODO 按钮时创建一个新的待办事项列表下面是我的启动脚本有人可以帮助我吗?

const classNames = {
  TODO_ITEM: 'todo-container',
  TODO_CHECKBOX: 'todo-checkbox',
  TODO_TEXT: 'todo-text',
  TODO_DELETE: 'todo-delete',
}

const list = document.getElementById('todo-list')
const itemCountSpan = document.getElementById('item-count')
const uncheckedCountSpan = document.getElementById('unchecked-count')
<div class="container center">
  <h1 class="center title">My TODO App</h1>
  <div class="flow-right controls">
    <span>Item count: <span id="item-count">0</span></span>
    <span>Unchecked count: <span id="unchecked-count">0</span></span>

  </div>
  <button class="button center" onClick="newTodo()">New TODO</button>
  <ul id="todo-list" class="todo-list"></ul>
</div>
  1. Create that function newTodo()创建 function newTodo()
  2. Inside newTodo , get that <ul> element by its id ( todo-list ) and append <li> inside of it.newTodo中,通过其 id ( todo-list ) 和append <li>获取该<ul>元素。

And I'm not sure why you're storing that class names in an array而且我不确定您为什么将 class 名称存储在数组中

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM