Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Rollover with a Mouse Event

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 266
    Comment on it

    With the help of JavaScript and html we create a "Rollover with a mouse event" function. Here we have two images. when we place mouse over image(1), the image(1) changes to image (2) and when we move the mouse away from that image, the original image,( i.e. image(1) ) gets displayed again.

    Code Sample:

    <script type="text/javascript">
    
    if(document.images){
        var image1 = new Image();     
        image1.src = "img/images (1).jpg";
        var image2 = new Image();  
        image2.src = "img/images (2).jpg";
    }
    </script>
    
    <body>
    <a href="#" onMouseOver="document.myImage.src=image2.src;"
                onMouseOut="document.myImage.src=image1.src;">
    <img name="myImage" src="img/images (1).jpg" />
    </a>
    </body>
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: