On Dec 10, 1:56 am, Bideshi <itbide...@gmail.com> wrote:
> i've a little issue related to siblings in jquery,
> i'm using sibling to deselect the previous selected link after
> clicking on the new link, but it's now working,
> please let me know where i'm missing.
> [ ... ]
>                 $("a").click(function(){
>                         $(this).toggleClass("bg");
>                         $(this).siblings("a").removeClass("bg");
>                 });
> [ ... ]
>     <li><a href="#">Link 1</a></li>
>     <li><a href="#">Link 2</a></li>

Your <A> tags aren't siblings; they're cousins.

Maybe something like this:

    $("a").click(function(){
        $(this).parents("ul").find("a").removeClass("bg");
        $(this).addClass("bg");
    });

Cheers,

  -- Scott

Reply via email to