Why this funcion add class only when you click on li elements that are originaly from html file. If i create new li element with add button, then add class doesnt work on it. How can i solve this?
<input type="text" id="new"><button id="add">Add</button>
<ul id="list">
<li >one</li>
<li>two</li>
<li>three</li>
</ul>
javascript
$(document).ready(function(){
$("li").click(function(){
$(this).addClass("current");
});
$("#add").click(function(){
var a=$("#new").val();
$("#list").append("<li>"+a+"</li>");
});
});