Grow your CSS skills. Land your dream job.

Help with Rollover Image Swap!

  • # May 23, 2010 at 12:49 am

    Hey!

    So I’m a newbie at JavaScript, and I’m having trouble using JavaScript to enable a mouseOver, mouseOut code. I am attempting to replace an image with another image.

    Here is my code:

    Code:
    < ?xml version = "1.0" encoding = "utf-8"?>
    < !DOCTYPE html PUBLIC = "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.we.org/TR/xhtml1/DTD/xhtml1-strict.dtd">






    TAH Background Essays for Students Image


    Can anybody please help me? I do not get what I am doing wrong.

    # May 23, 2010 at 8:05 pm

    Try something like this.

    the html:

    <div id="mydiv">
    </div>

    The css:

    #mydiv {

    background-image: img1.jpg;

    }

    #mydiv:hover {

    background-image: img2.jpg;

    }

    No javascript required ;)

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".