SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Evangelist
    Join Date
    Dec 2004
    Posts
    419
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    css class on hyperlink query

    Hi,

    I have noticed on this site:
    http://www.spinxo.com/

    That the HTML of each of the name suggestions is e.g. like this:

    <a target="blank" rel="nofollow" href='http://...'>NoamA1</a>

    But if you click on any of the name suggestion links, the little blue star changes to orange.

    If I inspect the HTML in FireBug, it shows this:

    <a target="blank" rel="nofollow" class="active" href='http://...'>NoamA1</a>

    I just wondered how the class of the link is changed on the link being clicked.

    I realise it might be JavaScript, so apologies if so, for posting in the wrong forum.

    Any advice much appreciated.

    Thanks

  2. #2
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,301
    Mentioned
    460 Post(s)
    Tagged
    8 Thread(s)
    Quote Originally Posted by bumpyride View Post
    I just wondered how the class of the link is changed on the link being clicked.

    I realise it might be JavaScript ...
    No, in normal circumstances this is handled by server-side code, such as PHP. If you are using a content management system, the system inserts that class when the page URL matches the link URL. You can do it manually on a static site, but it's not very efficient. An alternative is to use CSS, as explained here:

    http://www.sitepoint.com/forums/show...=1#post4930460

    There are some other solutions in that thread, too, which are worth a look. One is to highlight the links with JavaScript, though the downside of this is that it won't work if the user has JS off.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •