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 6 of 6
  1. #1
    New Coder
    Join Date
    Jul 2005
    Posts
    54
    Thanks
    2
    Thanked 1 Time in 1 Post

    css background image change.

    Hello Peeps.

    I hope someone can advice me on this one.

    I would like to be able to change the background image of a span through a mouseover link somewhere else on the page ie.

    Code:
    <span style="background:url('images/imagehere.gif') no-repeat;">content here</span>
    <br /><br />
    <a href="#">Change Background</a>
    I have looked everywhere and have found plenty of mouseover scripts but not to replace something somewhere else on the page.

    Really hope you can help.

    Thank you if you can.

    Lee

  • #2
    Regular Coder
    Join Date
    Oct 2006
    Posts
    206
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Give your span an id, then:

    PHP Code:
    <a href="javascript:document.getElementById('THE_ID').style.backgroundImage='NEW_IMAGE_PATH'">Change Background</a
    Inline JS isn't the best way to do it. Search around to find a better way.

  • #3
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    Onmouseout would you want the background image go back to its original image? If so then you don't need javascript.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #4
    New Coder
    Join Date
    Jul 2005
    Posts
    54
    Thanks
    2
    Thanked 1 Time in 1 Post
    Hello Chaps.

    thanks for the reply's.

    Yes I would like it go back to the origional backround on mouseout.

    Hope you an advise.

    Lee

  • #5
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    Check out these examples: http://bonrouge.com/cheerspics.php
    Tutorial here: http://bonrouge.com/~auto-gallery. Can be made to be used without php but if you have php available to you then you might as well use it.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #6
    New Coder
    Join Date
    Jul 2005
    Posts
    54
    Thanks
    2
    Thanked 1 Time in 1 Post
    Thanks for that but its not going to work for me.

    As there will be content in the span.

    It would be alot easier being able to use some form of javascript.

    Hope someone can advise.

    Lee


  •  

    Posting Permissions

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