I have a simple unordered list that is generated via $.ajax...
<ul id="simpleList"></ul>
After an ajax response it looks something like this:
<ul id="simpleList">
<li id="aaa">list item aaa</li>
<li id="bbb">list item bbb</li>
<li id="ccc">list item ccc</li>
</ul>
I need to move clicked list items from this list to another list (#selectedList).
Normally I'd use the .click function to handle this, but since the initial list items are created on the fly via an ajax call I've started using .live, but I'm still not able to get it to work. Here's an example of where I'm at so far.
$('#simpleList > li').live('click', function() {
console.log('click registered');
var contents = $(this).html();
var listId = $(this).attr('id');
$(this).remove();
$('#selectedList').show();
$('#selectedList').append('<li id="' + listId + '">' + contents + '</li>');
});
I'm expecting an end result like: (assuming the #aaa list item was clicked)
<ul id="simpleList">
<li id="bbb">list item bbb</li>
<li id="ccc">list item ccc</li>
</ul>
<ul id="selectedList">
<li id="aaa">list item aaa</li>
</ul>
But instead nothing happens at all (not even a console log). What am I missing?