Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Jun 2010
    Posts
    10
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Javascript background-image rollovers

    Hi guys,

    Just wanted to know (seeming im a bit of a jscript beginner).

    it is possible to have a background image rollover, and if so how.

    Thanks.

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,308
    Thanks
    203
    Thanked 2,563 Times in 2,541 Posts

  • #3
    New Coder
    Join Date
    Jun 2010
    Posts
    10
    Thanks
    1
    Thanked 0 Times in 0 Posts
    This almost answers my question, but I forgot to mention its for a button, so basically id have text on the top inside a div with hopefully on rollover the background image changing.

    Thanks

    for example at the moment I have

    <div id="home">home</div>

    #home {
    background-image:blah.jpg}
    Last edited by groundzeroginge; 06-22-2010 at 10:57 AM.

  • #4
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    27,603
    Thanks
    80
    Thanked 4,634 Times in 4,596 Posts
    You mean you want the <div>'s background image to change when the mouse is over the <input type="button">???

    Trivial:
    Code:
    <style>
    #home {
        background-image: url(blah.jpg);
    } 
    </style>
    ...
    <div id="home">
    home
    ...
    <input type="button" ... 
        onmouseover="document.getElementById('home').style.backgroundImage='url(foo.jpg)';"
        onmouseover="document.getElementById('home').style.backgroundImage='url(blah.jpg)';"
       />
    ...
    </div>
    The button doesn't have to be inside the div, either.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •