Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Jul 2009
    Thanked 0 Times in 0 Posts

    Exclamation changing 2nd or 3rd link css depending on page

    i have a div which has an id in that i have a div which has a class name then i have a table in the second div and in that i have few links (ie. <a href=...</a>)

    <div id="nav">
    <div class="moduletable_menu">
    <table width="100%" cellspacing="1" cellpadding="0" border="0">
    <td nowrap="nowrap">
    <a class="mainlevel" href="ssssssss">Home</a>
    <a class="mainlevel" href="ssssssssd">About</a>
    <a class="mainlevel" href="ddddddd">News2</a>
    <a class="mainlevel" href="ddddddd">News21</a>
    <a class="mainlevel" href="ddddddd">News4</a>
    <a class="mainlevel" href="ddddddd">News4</a>

    now i want to change the css of the link only on certain pages .

    So i was thinking wheteher i could get the current url of the page and if it is the right one then the propertioes of the 2nd or 3rd link change and if it is on another page the 1st link should change

    at any time i may require to chnage atleast one link

    so i will require either javascript code which if on the right page selects the 2nd or third link to change and on another page the 1st link

    How will i achieve this

    can anybody please help me

  2. #2
    Senior Coder rnd me's Avatar
    Join Date
    Jun 2007
    Thanked 626 Times in 605 Posts
    css can do it without javascript.

    give each link a different class (eg link1), and each body a different class (i used main and other in the example below).

    then you can use one stylesheet that has section like this:

    .main .link1, .main .link2 { color: black; }
    .main .link3 { color: red; }
    .other .link1, .main .link3 { color: black; }
    .other .link2 { color: red; }
    you can define all three pages' style in the same css file, and it works without javascript enabled...
    Create, Share, and Debug HTML pages and snippets with a cool new web app I helped create: pagedemos.com

  3. #3
    New to the CF scene
    Join Date
    Jul 2009
    Thanked 0 Times in 0 Posts
    i think that you want to make a 'nav'
    i have a project just last month ,can be help just a littel!!!
    you may visite to http://www.zhilian100.com.cn for looking 'nav' coding, it made by javascript and CSS
    hoping can be help goodluck!!!


Posting Permissions

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