Does anyone knows why I cannot remove the letter B in the list?
Steps to reproduce:
- click on "Add to list" button
- letter B is added to the list
- click on letter B in the list to remove
- letter B is not removed from list
- click on letter C or A
- letter C or A is removed from list
HTML:
<button id="add">Add to list</button>
<ol>
<li>A</li>
<li>A</li>
<li>A</li>
</ol>
Jquery:
$(document).ready(function(){
$("ol").append("<li>C</li");
$("#add").click(function(){
$("ol").append("<li>B</li>");
});
$("li").on("click",function(){
$(this).remove();
});
});
Here you have the sample in the jsfiddle.
Best regards.