Change CSS id with Java or PhP

  • seularts
  • Graduate
  • Graduate
  • User avatar
  • Posts: 153
  • Loc: Romania

Post 3+ Months Ago

Is there a way to change the id for a CSS link with Java/PhP, so that it can remain active when clicked!?

This is my example of the css:

#inactive{
font-size:1.5em;
}

#active{
font-size:1em;
}

And the link:

<a href="" id="inactive">Link</a>

The idea is to make the link change into the #active id when clicked!
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • Bogey
  • Genius
  • Genius
  • Bogey
  • Posts: 8388
  • Loc: USA

Post 3+ Months Ago

Why not just use:
CSS Code: [ Select ]
a:link {
font-size:1.5em;
}
 
a:visited {
font-size:1em;
}
  1. a:link {
  2. font-size:1.5em;
  3. }
  4.  
  5. a:visited {
  6. font-size:1em;
  7. }

That would make the link stay like that... or...
CSS Code: [ Select ]
a:link {
font-size:1.5em;
}
 
a:active {
font-size:1em;
}
  1. a:link {
  2. font-size:1.5em;
  3. }
  4.  
  5. a:active {
  6. font-size:1em;
  7. }

That would make the link smaller when clicked and back to original state when released.
  • seularts
  • Graduate
  • Graduate
  • User avatar
  • Posts: 153
  • Loc: Romania

Post 3+ Months Ago

Sorry, my example was to simple, i wanted to make the css change for a link that can change it's background when clicked. But I solved it like this:
Code: [ Select ]
<ul>
<li><a href="javascript:ajaxpage('a.txt', 'cont');" id="link1" onclick="changeActiveStates(this)">Home</a></li>
</ul>
<script type="text/javascript">
function byId(id) {
return document.getElementById ? document.getElementById(id) : document.all[id];
}
var prevLink = "";
function changeActiveStates(ele) {
if (prevLink) byId(prevLink).className = "";
ele.className = 'activate';
prevLink = ;
}
  1. <ul>
  2. <li><a href="javascript:ajaxpage('a.txt', 'cont');" id="link1" onclick="changeActiveStates(this)">Home</a></li>
  3. </ul>
  4. <script type="text/javascript">
  5. function byId(id) {
  6. return document.getElementById ? document.getElementById(id) : document.all[id];
  7. }
  8. var prevLink = "";
  9. function changeActiveStates(ele) {
  10. if (prevLink) byId(prevLink).className = "";
  11. ele.className = 'activate';
  12. prevLink = ;
  13. }

and used a class named .active to do the rest of the job:D
  • seularts
  • Graduate
  • Graduate
  • User avatar
  • Posts: 153
  • Loc: Romania

Post 3+ Months Ago

at prevLink = ; i had to remove the content, ozzu doesn't like the code:)) but the rest there, before the ';' was ele . id

Post Information

  • Total Posts in this topic: 4 posts
  • Users browsing this forum: wpas and 73 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
cron
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.