bleustreak12 Posted July 24, 2009 Share Posted July 24, 2009 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 Quote Link to comment Share on other sites More sharing options...
haku Posted July 24, 2009 Share Posted July 24, 2009 An easier way to do this is purely in CSS. Give the body on the pages you want to change the links a class. Ex: <body class="link_changer"> Then you use: .link_changer #nav table a { //css here } Which will only change the links on the pages that have that class entered into the body. But to be honest, you have some very invalid code there. You should validate it before proceeding or you will end up with much worse headaches in the future. Quote Link to comment Share on other sites More sharing options...
bleustreak12 Posted July 24, 2009 Author Share Posted July 24, 2009 Thanks But the thing is i cannot change my html source now so i have to deal with whatever is already there in my html is there any other way? Quote Link to comment Share on other sites More sharing options...
bleustreak12 Posted July 24, 2009 Author Share Posted July 24, 2009 can somebody atleast tell me how to select the third or fourth link in a table without having to change the html source Quote Link to comment Share on other sites More sharing options...
bleustreak12 Posted July 24, 2009 Author Share Posted July 24, 2009 i just want to change a certain link border and color without changing the source Quote Link to comment Share on other sites More sharing options...
bleustreak12 Posted July 24, 2009 Author Share Posted July 24, 2009 could i not get javascript to loop through the links in the table in the div and change or give different css styling or files to each link Quote Link to comment Share on other sites More sharing options...
haku Posted July 24, 2009 Share Posted July 24, 2009 Dude, be patient. That's four replies without giving anyone time to help you. How annoying. What is the determining factor in whether the link should be changed? Quote Link to comment Share on other sites More sharing options...
bleustreak12 Posted July 24, 2009 Author Share Posted July 24, 2009 i want to change it on certain pages Quote Link to comment Share on other sites More sharing options...
haku Posted July 24, 2009 Share Posted July 24, 2009 That doesn't answer the question. How do you know which link should be changed? What makes the link different from the other links? Without that information, you cannot target the link specifically. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.