0
Why does the x button only work on the test list items i made in html and not the ones made with js
2 odpowiedzi
+ 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())
+ 1
write something like this after creating element
$( elem).bind( "click", function() {
$(this).remove();
});