I'm fairly sure that, while on index.html, <a
href="index.html">Frontpage</a> isn't "active".  At least, not as far as the
:active pseudo-class goes.

a:active refers to the a element that is actively receiving a click event.

If you were to do:

<div id="menu">
     <a href="index.cfm" class="active">Frontpage</a>
     <a href="contact.html">Contact</a>
</div>

... then you could do $('#menu a.active')

On Thu, Aug 20, 2009 at 3:41 PM, Dennis Madsen <den...@demaweb.dk> wrote:

>
> No, not really! Say I'm on the page index.html, where I have this
> HTML:
>
> <div id="menu">
>   <a href="index.html">Frontpage</a>
>   <a href="contact.html">Contact</a>
> </div>
>
> Since I'm on the index.html-page, the first a-tag is "active" in CSS.
> I would like jQuery to give my the active a-tag in my menu-div.
>
> Hope you understand my problem now.
>
> On Aug 21, 12:33 am, Charlie Griefer <charlie.grie...@gmail.com>
> wrote:
> > an "active" link is one that has received a click.
> >
> > so you can do:
> >
> > $('a').click(function() {
> >      $(this).doSomethingHere  // 'this' is a reference to the element
> that
> > triggered the click
> >
> > });
> >
> > does that help?
> >
> > On Thu, Aug 20, 2009 at 3:30 PM, Dennis Madsen <den...@demaweb.dk>
> wrote:
> >
> > > I've this CSS to style my links in my menu:
> > > .menu a:link, .menu a:active, .menu a:visited{
> > >    color: #ffffff;
> > >    text-decoration: none;
> > > }
> >
> > > I would like to find the a-tag (<a>) which is active. I've tried
> > > something like: $('.menu a:active').
> >
> > > How can I find that element?
> >
> > --
> > 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.
>



-- 
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.

Reply via email to