0

Why does the x button only work on the test list items i made in html and not the ones made with js

https://code.sololearn.com/WgbPCwOgiLeF/?ref=app

3rd Nov 2021, 12:49 AM
Jeremy MCSSJ
2 Respuestas
+ 1
Jeremy MCSSJ There is no click event handler attached to the newly added list item. You need to attach the click event handler to the newly added element. Just add the following line in the 8th line of JS section. Your code will work fine. elem.children('button').on('click',()=>elem.remove())
3rd Nov 2021, 1:51 AM
Art1mis
+ 1
write something like this after creating element $( elem).bind( "click", function() { $(this).remove(); });
3rd Nov 2021, 1:53 AM
Daniel Rodriguez
Daniel Rodriguez - avatar