Change html on mouseover?

Discussion in 'JavaScript' started by mattmdesign, Sep 6, 2006.

  1. #1
    Hi,

    Does anyone know where I can find the code to do this?

    When image1.gif is moused over, change this code that is at the top of the page:

    background="http://www.domain.com/bg.gif" style="background-attachment:fixed; background-color:#C1C0C1; background-repeat:repeat-x;"

    to this:

    background="http://www.domain.com/image1.gif"

    Thanks!
     
    mattmdesign, Sep 6, 2006 IP
  2. ccoonen

    ccoonen Well-Known Member

    Messages:
    1,606
    Likes Received:
    71
    Best Answers:
    0
    Trophy Points:
    160
    #2
    setup 2 css classes. one with one img, one with the other, then put an anchor around the "Initializer" image and on the anchor tag put onclick="javascript:document.getElementById("imgToChangeID").className="newClass";

    so your not changing the bg image, your changing the class which has a differet bg img associated with it.
     
    ccoonen, Sep 7, 2006 IP
  3. mattmdesign

    mattmdesign Well-Known Member

    Messages:
    1,201
    Likes Received:
    77
    Best Answers:
    0
    Trophy Points:
    118
    #3
    Thanks for the reply, ccoonen. I have a ton of images though (I should've mentioned that), and I don't really want to create a css class for each one. Can anyone think of another way?

    Thanks, Matt
     
    mattmdesign, Sep 9, 2006 IP