Hmmm, I take that back. It still seems like the is() is able to select child elements of the anchor, so when you have an anchor set as block, with a few spans to style text, it is hard to click on the actual anchor to give it the class. Is this normal?
On Aug 26, 11:37 am, hubbs <[EMAIL PROTECTED]> wrote: > Thank you, that fixed it. > > Is the limitation of is() a javascript limitation, or a jQuery > limitation? Would this be coming in a new version of jQuery? > > Also, with event delegation, would you recommending using it for all > event instances on a page? I have a few places where a single click > event is added to an ID, and I figure it is really not necessary to > mess with event delegation there. > > On Aug 26, 11:31 am, Ariel Flesler <[EMAIL PROTECTED]> wrote: > > > Note that is() doesn't accept complex selectors (yet). The reason of > > your problems is probably this. > > Event delegation is surely the best approach, if you can live with its > > difficulties. > > > -- > > Ariel Fleslerhttp://flesler.blogspot.com > > > On Aug 26, 2:31 pm, hubbs <[EMAIL PROTECTED]> wrote: > > > > 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"); > > > } > > > });