JavaScript JavaScript and the DOM Traversing the DOM Using previousElementSibling and insertBefore

Rod R
Rod R
3,047 Points

my 'up' buttons are removing list items instead of moving up

https://w.trhou.se/ee3rmjnk3n

I've reviewed the code multiple times and compared with the video, and there's no JS console error, but the UP buttons are removing items. Where's the error?

1 Answer

Daniel Baker
Daniel Baker
15,351 Points

Try == or ===?

//original line 13
 if (event.target.className="remove") {

//fixed
if (event.target.className == "remove") {

//You got it right in line 18
if (event.target.className == "up") {

I'm sure you know what the single = does from the rest of your code, so I am assuming you don't need me to explain that you are trying to assign "remove" to event.target.className. I am assuming it's just a typo.