I am working to replace all of my uses of livequery with event delegation (is this even a good idea?) and have a few questions.
I have a simple script that will add a "selected" class to a link when it is clicked. It does work using event delegation, but it seems that it is not limiting it to anchor tags, but will also add the "selected" class to any spans that are inside my anchor. This seems strange, and is not what I want, is something wrong with the following code? $('body').click(function(event) { var $target = $(event.target); if ($target.is('.scroll a')) { $("a.selected").removeClass("selected"); $(event.target).addClass("selected"); } });