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
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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.