Highlights
All Snippets
Top 100 Snippets
Librarians
gbCodeLib

By Language
VB6
JavaScript
Perl
HTML
SQL
Java
DOS

GBIC >> Source Code >> JavaScript >> Snippet

Rollover


when mouse moves over the image, the image changes.
when mouse moves away from the image, the image returns to it 's prior state

can use the < a > or < img > tag - both support the onMouseover event

Method 1 -------------------------------------------------
< img src = "iimage1.jpg" name = "myimage" onMouseover = "document.myimage.src='image1.jpg' " onMouseout = "document.pic1.src='image2.jpg'" >

Method 2 (faster) -------------------------------------
< img src = "image1.jpg" name = "pic1" >
< img src = "image2.jpg" name = "pic2" >
< img src = "image1.jpg" name = "myimage"
   onMouseover = "document.myimage.src=document.pic2.src"
   onMouseout = "document.myimage.src=document.pic1.src" >