Friday, June 5, 2009

[jQuery] Re: Dynamic underlining for links on a page

Thanks for that, I'll give it a go!
 

On 9 May 2009, at 21:31, Charlie Griefer wrote:


On Sat, May 9, 2009 at 4:41 AM, naz <nazimjamil@gmail.com> wrote:

Hello all, probably a simple question but I can't for the life of me
figure out how to do this:

I have a page that has information on various # anchors, a list of
them are at the top and once clicked I need the one clicked to become
underlined and remain underlined untiled a different # is clicked.

How on earth do I do this? I've managed to use jquery toggle to turn
on an underline once it is clicked, but i have to click the same link
again to turn it off, which is not what I want, I need it to
automatically turn off once a different link is clicked!

assume they all have a class of "myAnchor"

$('.myAnchor').click(function() {
    $('.myAnchor').css('text-decoration', 'none');
    $(this).css('text-decoration','underline');
});


--
I have failed as much as I have succeeded. But I love my life. I love
my wife. And I wish you my kind of success.

No comments: