This code works with jQuery 1.7.2:
$('.category').live('click', function() {
alert('clicked');
});
But when I switch to use addClass, no class is added:
$('.category').live('click', function() {
$(this).addClass('active');
});
Can anyone advise as to why and how to use live() to do this? Thanks.
Update: I switched to the 2.2.4 version of jquery and changed the live() function for the on() function. The alert works when I target either a link created dynamically or a DOM element that is not dynamically created. However, the addClass() only works when I target an element that was *not dynamically created, and the inspector shows the active class is added for those elements, but not added to the dynamically created links.