Hello and welcome to our community! Is this your first visit?
Register
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
    Posts
    2
    Thanks
    0
    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">
    <ul>
    <div class="moduletable_menu">
    <table width="100%" cellspacing="1" cellpadding="0" border="0">
    <tbody>
    <tr>
    <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>
    </td>
    </tr>
    </tbody>
    </table>
    </div>
    </ul>
    </div>

    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
    Senior Coder rnd me's Avatar
    Join Date
    Jun 2007
    Location
    Urbana
    Posts
    4,296
    Thanks
    10
    Thanked 584 Times in 565 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:

    Code:
    .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...
    my site (updated 13/9/26)
    BROWSER STATS [% share] (2014/5/28) IE7:0.1, IE8:5.3, IE11:8.4, IE9:3.2, IE10:3.2, FF:18.2, CH:46, SF:7.9, NON-MOUSE:32%

  • #3
    New to the CF scene
    Join Date
    Jul 2009
    Posts
    2
    Thanks
    0
    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
    •