If I make that remove button with id attribute it isnt working. When I make it with class attribute it is working. Why its not working with id?
$(function() {
$("#btn").on("click", function() {
var val = $("#yzbr").val();
if (val !== '') {
var elem = $("<li></li>").text(val);
$(elem).append("<button id='rem'>REMOVE</button>");
$("#ekl").append(elem);
$("input").val("");
$("#rem").on("click", function() {
$(this).parent().remove();
})
}
})
})
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<h1>list</h1>
<input type="text" id="yzbr">
<button id="btn">add</button>
<ol id="ekl"></ol>