From the course: JavaScript: Enhancing the DOM
Unlock this course with a free trial
Join today to access over 25,300 courses taught by industry experts.
Manipulating lists
From the course: JavaScript: Enhancing the DOM
Manipulating lists
- [Instructor] Lists, both ordered and unordered, are building blocks for organized content on the web. It's time to dynamically manipulate these lists using DOM techniques. Imagine adding items to your shopping list or reordering tasks in your to-do list. That's what we're going to replicate. We'll use methods like createElements, appendChild, removeChild, to dynamically manage these lists. Here's the example to-do list. Right now it's not doing anything, but I want to be able to add tasks here. When I click the button Add Task, it should appear in my list. I want to be able to remove the first task and to prioritize the last task, meaning it should move up. And here's the code for a to-do list. We have a todoListContainer and an unordered list todoList. Then we have an addTaskButton, a removeFirstTaskButton, and a prioritizeLastTaskButton. Here I'm having my JavaScript. I already selected all those elements that I need. And let's start with the first snippet of functionality, adding…