Jump to content

[SOLVED] mouseon and off help


rallokkcaz

Recommended Posts

i wanna try to make a link that when the mouse is over it, it is white, and when there is no mouse over it, its a light grey.

 

would the code go something like this ?

 

function rollonoff() 
{
if (mouseon) {
document.getElementById(a).style.color="#000000"
} else if (mouseoff) {
document.getElementById(a).style.color="#030303"
}

i know thats probly wrong as hell but u see my point

Link to comment
https://forums.phpfreaks.com/topic/46911-solved-mouseon-and-off-help/
Share on other sites

First off, you'd be better off using straight CSS for that:

a {color: #000000;}
a:hover {color: #030303;}

 

However, to answer your question directly, you could do it with javascript like this:

function initLinks() {
  // gather all your links
  eles = document.getElementsByTagName('a');
  for (i = 0; i < eles.length; i++) {
    eles[i].onMouseOver = function() {
      this.style.color = "#000000";
    }

    eles[i].onMouseOut = function() {
      this.style.color = "#030303";
    }
  }
}

window.onload = initLinks;

 

This function, if run once your page loads, will loop through all the links on your page and set up their onmouseover and onmouseout function calls.

 

**EDIT**

Based on your update, you can use the exact same principle, but target your table instead of the anchor tags with the above function assignments.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.