Wrox Home  
Search P2P Archive for: Go

  Return to Index  

javascript thread: Swaping css classes


Message #1 by joee@v... on Fri, 18 Oct 2002 00:38:20
At 12:38 AM -0700 10/18/02, joee@v... wrote:
>I have a left frame in my page that houses navigation. The navigation is
>made up of 90 links, each link in its own table cell with its own unique
>ID. When I click a link I change the table cell class from leftNav to
>leftNavUp. That i can do, but how would I change back a previous link that
>was clicked from leftNavUp to leftNav? I would like to be able to loop
>through the page and change the classes back to leftNav, put keep the one
>I clicked at leftNavUp.
>
>Thanks

How about something like this:


prevCell = null;  // Global variable

// onClick handler for navigation table cells.
// Argument thisCell is the cell that was clicked on.
// Cells are defined as:  <td class='leftNav' onClick='newNavUp(this)'>
function newNavUp(thisCell) {
   if (prevCell) prevCell.className='leftNav';
   prevCell = thisCell;
   thisCell.className = 'leftNavUp';
   // ...and whatever else you do when a cell is clicked... //
}


--Greg

  Return to Index