Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CSS mouseover help...newbie

Status
Not open for further replies.

craazycanuck

Technical User
Apr 28, 2001
7
CA
Could someone please shed some light on what I am missing to allow this mouseover to function
Thank you in advance

<style type=&quot;text/css&quot;>
.oneclass { width:40; height:15; background-color:yellow; color:red;}
.anotherclass {width:40; height:15; background-color:red; color:yellow;} </style>
<span id=thisspan class=oneclass onmouseover=somefunction()>button
<script>
somefunction(){
document.all.thisspan.className = anotherclass;
}
</script>

 
Not sure if this will work or not, but try putting the <script> code between the <head></head> tags....
 
You need quotes:

document.all.thisspan.className = &quot;anotherclass&quot;;

also, to make you're life easier, consider:

somefunction(obj){
obj.className = &quot;anotherclass&quot;;
}

<span id=&quot;thisspan&quot; onmouseover=&quot;somefunction(this)&quot; class=&quot;oneclass&quot;>

that way you can take advantage of the this keyword (which referes to the calling object in a particular context of execution, in this case: thisspan) and be able to apply the event handler easily to other elements as well. jared@eae.net -
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top