Because the elements that you are appending do not exist when you define the the click handler, they are created dynamically. To fix this you can use the delegate() method from jQuery.
$('ul').delegate('a','click',function() {
// your code here ...
});
Online example: http://jsfiddle.net/J5QJ9/