Thanks, James!

the :has() selector did not work on the 'if' statement, but you put me
on the right track.

the code now looks like this:

        $('ul#hoofdNavigatieLijst > li > ul > li:has("ul") > a ').click
(function(event) {
                event.preventDefault();
                });

and it works like a charm.

thanks again!

On 21 aug, 22:09, James <james.gp....@gmail.com> wrote:
> I think you want to use :has() selector instead of 
> contains().http://docs.jquery.com/Selectors/has
>
> I think contains() works only for text nodes and not elements. I
> haven't tested it to be sure.
>
> On Aug 20, 9:06 pm, Hans <deboem...@gmail.com> wrote:
>
>
>
> > hello everybody,
>
> > the site I'm building has a dropdown menu based on an unordered list
> > with 3 levels. I've got it working nicely using jQuery, but there is
> > one thing I can't get working..
>
> > this is the problem:
>
> > the 'a href' on the first tow levels serves to open up the level below
> > without leaving the page. there is a real link for the non-script
> > users, so I have switched off the first two levels using
> > "event.preventDefault();"
>
> > however, on the second level some items do not contain any 3rd level
> > links, so in that case the user should navigate away using the 2nd
> > level link. therefore the link on level 2 should one be disabled if
> > the list-item contains a list (ul).
>
> > I tried doing this:
>
> >         $('ul#hoofdNavigatieLijst > li > ul > li > a 
> > ').click(function(event)
> > {
> >                 if ($(this).parent('li').contains('ul')) {
> >                 event.preventDefault();
> >                 }
> >                 });
>
> > it doesn't do the trick, however.
>
> > can anyone help me? thanks!- Tekst uit oorspronkelijk bericht niet 
> > weergeven -
>
> - Tekst uit oorspronkelijk bericht weergeven -

Reply via email to