Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript jQuery navigation tabs

  • This topic is empty.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #29782
    soap
    Participant

    This is probably a stupidly easy thing to do but I never really figured it out.

    What’s an easy way (not necessarily with jQuery) to have nav tabs be in a certain "on" state depending on which page you’re on?

    Here’s an example: http://www.dribbble.com/

    Possibly done easily with PHP? I’m not so good with PHP but am a fast learner and willing to learn.

    Thanks for any help!!

    #80632
    jamygolden
    Member

    You could have something like this:
    about.html

    Code:
    <body class="about">
    <ul>
    <li class="home"><a href="home.html">home</a></li>
    <li class="contact"><a href="home.html">home</a></li>
    <li class="about"><a href="home.html">home</a></li>
    </ul>
    </body>

    The CSS

    Code:
    ul li{background: red;}
    body.home ul li.home {background: green;}
    body.contact ul li.contact {background: green;}
    body.about ul li.about {background: green;}

    Where <body class="about"> is changed depending what page you are on

    #71938
    soap
    Participant

    Very belated thanks jamy_za.

    I look at this post I wrote in July and it’s so trivial to me, haha.

    I was such a noob.

Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.