Jump to content

Javascript Help!!!


Guest citrus_cyanide

Recommended Posts

Guest citrus_cyanide

Please, I need to make this code work just one time so that I can understand it and start making my own similar functions, please tell me what is wrong with this code.

<html><head><title>JS Test.</title><script type="text/javascript">function hover(){// Loops through all td tagsvar tds=document.getElementsByTagName('td');for(var i=0;i<tds.length;i++){// If the td tag has class="hover" then it adds mouseover and mouseoutif(tds[i].className=='hover'){tds[i].onmouseover=function(){this.classname="hon"}tds[i].onmouseout=function(){this.classname="hoff"}}}}window.onload=function(){hover()}</script><style>table.hon{background-color:#444444}table.hoff{background-color:#000000}</style></head><body><table bgcolor="#000000"><tr><td class="hover"><font-color="ffffff">HURRY UP AND WORK ALREADY!!!</td></tr></table></html>

Like I said, I only need to get this to work once. Just give me a working example and I will be able to figure out how to integrate it how I want. Thanks alot. P.S. I use htis format because I rely heavily on CSS.

Link to comment
Share on other sites

window.onload=function(){hover()}First of all, i'm pretty sure it's window.onload="function(){hover()}"And you can put that in the body-onload section. Also, that makes no sense..window.onload=function(){hover()}Just use window.onload="hover()"

Link to comment
Share on other sites

  • 2 weeks later...
<font-color="ffffff">

I can guarantee that code doesn't work properly...Also, you should declare your style type, like this (assuming it's css):
<style type="text/css"></style>

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...