I am trying to dynamically add a list item to a list and then remove it by clicking on that item. The remove event never seems to fire. However if I use the same code on a static list it works fine. I've seen similar solutions but they do not work.
See jsFiddle: http://jsfiddle.net/Lc2bC/
<input id="status" type="text" placeholder="Status (tab or enter)">
<br/>
Dynamic List:
<ul id="statusList"></ul>
$('#status').keydown(function (e) {
if (e.which == 9 || e.which == 13) {
$('#statusList').html($('#statusList').html() + formatNewStatus(this.value));
this.value = "";
this.focus();
e.preventDefault();
}
});
$(function () {
$('#statusList li').click(function () {
alert('dynamicList');
$(this).remove();
})
});