That's THE solution. It's (nearly) the same as using e.stopPropagation(). -- Ariel Flesler http://flesler.blogspot.com
On 5 jun, 09:24, Argasek <[EMAIL PROTECTED]> wrote: > This is my first post here, so hello to all subscribers! > > I have googled a bit for my problem, but didn't find exact answer to > my problem, or I do not understand event propagation enough. The > situation looks like this: I have a nested list: > > <ul class="someclass"> > <li>1 Position... <a href="mailto:[EMAIL PROTECTED]">e-mail</a></ > li> > <li>2 Nested position > <ul class="nested"> > <li>1.1 Position... <a href="mailto:[EMAIL PROTECTED]">e- > mail</a></li> > ... > </ul> > </li> > </ul> > > There's an event (click; toggle, to be more exact) bound to each > ('ul.someclass > li'), making <ul> contained within this <li> > (ul.nested) appear/disappear. The problem is: the event is triggered > not only when I click on the "2 Nested position" label, but also when > clicking on any of this element (i.e. ul.someclass > li) descendants, > thus, preventing the "default action" for an anchor > (mailto:[EMAIL PROTECTED]). > > I have made a simple workaround: > $('.someclass > ul > li a').click(function(e) { > document.location.href = $(this).attr('href'); > return false; > }); > > which works, but I'm not quite happy with the solution. > > The question is: is there any way to easily prevent "propagation" > described above? > > I can provide a link to a live code, if needed. > > greetings, > Jakub