Changing a div's background image on hover

Discussion in 'JavaScript' started by chulium, Nov 27, 2005.

  1. #1
    Hey,

    I have this site:

    www.iLookup.info

    I'm working hard on its interface. In Firefox it works fine, but in IE, when you hover the mouse over the execute button, it doesn't glow :( How can I change the div's bg image with javascript? (Or can I use CSS differently than I do now?)

    Thanks,
    -Matt
     
    chulium, Nov 27, 2005 IP
  2. NetMidWest

    NetMidWest Peon

    Messages:
    1,677
    Likes Received:
    151
    Best Answers:
    0
    Trophy Points:
    0
    #2
    NetMidWest, Nov 27, 2005 IP
  3. chulium

    chulium Well-Known Member

    Messages:
    1,438
    Likes Received:
    70
    Best Answers:
    0
    Trophy Points:
    140
    #3
    I can't figure it out :(

    If anybody could help me specifically with iLookup, it'd be GREATLY appreciated.

    Thanks though ;)
     
    chulium, Nov 27, 2005 IP
  4. BurgerKing

    BurgerKing Active Member

    Messages:
    397
    Likes Received:
    23
    Best Answers:
    0
    Trophy Points:
    58
    #4
    Use..

    onmouseover="javascript:glowOn();" onmouseout="javascript:glowOff;"

    in the definition of the div

    glowOn and glowOff are javascript functions that you define to make your divs glow
     
    BurgerKing, Nov 30, 2005 IP
    saadahmed007 likes this.
  5. thewantedhost

    thewantedhost Peon

    Messages:
    43
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    function glowOn() {
    document.getElementById("ID OF OBJECT").style.backgroundImage = "url('path/to/secondaryimage.jpg')";
    }
    function glowOff() {
    document.getElementById("ID OF OBJECT").style.backgroundImage = "url('path/to/originalimage.jpg')";
    }
     
    thewantedhost, Feb 6, 2011 IP
  6. srisen2

    srisen2 Peon

    Messages:
    359
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #6
    you can always place the functions directly in the onmouseover and onmouseout declarations directly as well
     
    srisen2, Feb 6, 2011 IP
  7. AtSeaDesign

    AtSeaDesign Active Member

    Messages:
    172
    Likes Received:
    2
    Best Answers:
    1
    Trophy Points:
    93
    #7
    the only issue with using js for mouseover is if your users have javascript disabled. Why not use css to do this?
     
    AtSeaDesign, Feb 7, 2011 IP
  8. srisen2

    srisen2 Peon

    Messages:
    359
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #8
    so how would you process this without javascript as i have never seen a pure css solution for something like this. please do tell us..
     
    srisen2, Feb 7, 2011 IP
  9. AtSeaDesign

    AtSeaDesign Active Member

    Messages:
    172
    Likes Received:
    2
    Best Answers:
    1
    Trophy Points:
    93
    #9
    AtSeaDesign, Feb 7, 2011 IP
  10. srisen2

    srisen2 Peon

    Messages:
    359
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #10
    very cool thanks for sharing.
     
    srisen2, Feb 7, 2011 IP