You are not using the correct code to get live functionality.
$('#title-items').on('click', 'a', function(e) {
alert('clicked');
e.preventDefault();
});
- First, select your common ancestor element (
#title-items
in this example). You can usedocument
here too if you want to handle alla
elements. - Pass the event type (
on
), then the sub selector (a
), and then the callback function for the event.
Now, when click
events bubble up to #title-items
, it will check to see if the element is an a
element, and if so, fire the callback.