You could give them all the same name (because sadly there isn't a function to grab class name) grab them all and then attach an event listener via:
var elements = document.getElementsByName("mouseOverName"); /* NOTE Remember the s in getElements */
for(var i = 0; i < elements.length; i++)
{
elements[i].addEventListener('onmouseover',doSomething,false);
function doSomething() {
this.style.backgroundColor = '#cc0000';
}
} You will have to do the above after the dom has loaded by putting the above in a function and attaching the function to the documents onload function
<body onload=attachListeners();> or you can look into jQuery and use
$(document).ready(function(){
$(".yourClassNameHere").mouseover(function()
{
this.style.backgroundColor = '#cc0000';
});
}); Some links to check out: http://www.javascript.com/
http://api.jquery.com/mouseover/
http://jquery.com/
http://www.quirksmode.org/js/events_advanced.html
scrappedcola
Posting Whiz in Training
227 posts since Dec 2009
Reputation Points: 27
Solved Threads: 45