简体   繁体   中英

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?

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()
  2. Inside newTodo , get that <ul> element by its id ( todo-list ) and append <li> inside of it.

And I'm not sure why you're storing that class names in an array

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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