Page 1 of 1

Class of js?

Posted: Wed Apr 27, 2005 10:42 pm
by Todd_Z
Can I assign the same onMouseOver, onMouseOut events to a group of <td>'s?

Posted: Thu Apr 28, 2005 1:54 am
by n00b Saibot
assign the events to them in a loop...

Posted: Wed May 04, 2005 9:48 pm
by Todd_Z
Ok, to achieve that, I would like to figure out how to iterate over all the td's in a div.

Code: Select all

<div id=&quote;nav&quote;>
 <table width=&quote;100%&quote; cellpadding=&quote;2&quote; cellspacing=&quote;0&quote;>
  <tr>
   <td onclick=&quote;window.location='?page=Home';&quote; onmouseover=&quote;this.className='selected';&quote; onmouseout=&quote;this.className='';&quote;>Home</td>
   <td onclick=&quote;buttonClick(event, 1);&quote; onmouseover=&quote;this.className='selected';&quote; onmouseout=&quote;this.className='';&quote;>Reviews</td>
   <td onclick=&quote;window.location='?page=Recent Releases';&quote; onmouseover=&quote;this.className='selected';&quote; onmouseout=&quote;this.className='';&quote;>Recent Releases</td>
   <td onclick=&quote;window.location='?page=Coming Soon';&quote; onmouseover=&quote;this.className='selected';&quote; onmouseout=&quote;this.className='';&quote;>Coming Soon</td>
   <td onclick=&quote;window.location='?page=Cast And Crew';&quote; onmouseover=&quote;this.className='selected';&quote; onmouseout=&quote;this.className='';&quote;>Cast And Crew</td>
   <td onclick=&quote;buttonClick(event, 2);&quote; onmouseover=&quote;this.className='selected';&quote; onmouseout=&quote;this.className='';&quote;>Links</td>
   <td onclick=&quote;buttonClick(event, 3);&quote; onmouseover=&quote;this.className='selected';&quote; onmouseout=&quote;this.className='';&quote;>Media</td>
   <td onclick=&quote;window.location='?page=About';&quote; onmouseover=&quote;this.className='selected';&quote; onmouseout=&quote;this.className='';&quote;>About</td>
   <td onclick=&quote;window.location='?page=Contact';&quote; onmouseover=&quote;this.className='selected';&quote; onmouseout=&quote;this.className='';&quote;>Contact</td>
   <td onclick=&quote;buttonClick(event, 4);&quote; onmouseover=&quote;this.className='selected';&quote; onmouseout=&quote;this.className='';&quote;>Search</td>
  </tr>
 </table>
</div>
So i'd like to iterate all of the tds in the div marked "nav" and then assign onmouseover="this.className='selected';" onmouseout="this.className='';" to each - How could i do this?