rallokkcaz Posted April 13, 2007 Share Posted April 13, 2007 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 Quote Link to comment Share on other sites More sharing options...
rallokkcaz Posted April 13, 2007 Author Share Posted April 13, 2007 i stated what i said wrong i want the like a table to changle color not a link sorry for the confusion Quote Link to comment Share on other sites More sharing options...
obsidian Posted April 13, 2007 Share Posted April 13, 2007 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. Quote Link to comment Share on other sites More sharing options...
rallokkcaz Posted April 13, 2007 Author Share Posted April 13, 2007 im gonna take your code and edit it so it fits to what i need and sorry for the confusing i didn't mean link i meant like a ,li, or tr Quote Link to comment Share on other sites More sharing options...
rallokkcaz Posted April 13, 2007 Author Share Posted April 13, 2007 i figured it out thanks to CSS! thanks tho guys!! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.