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 2 of 2
  1. #1
    New Coder
    Join Date
    Jul 2011
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Javascript Background/Content Change Help

    I have a div that changes background on click.
    Example:

    <script type="text/javascript">

    function changeBackground(strURL)
    {
    document.getElementById('about').style.backgroundImage="url("+strURL+")";
    }

    </script>

    <body>

    <div id="about">
    <a href="#about" onClick="changeBackground('mainbackground.jpg');">text</a>
    <a href="#about" onClick="changeBackground('background2.jpg');">text</a>
    </div>

    This part works just fine so no issues.

    However, I have content on the mainbackground.jpg that is getting transferred over to the other backgrounds as well.

    I would like each background to have its own paragraph content. I do not want to embed the info into the images for SEO reasons.

    Any ideas on how to do this?

    Thanks!
    Last edited by savagebeauty; 07-31-2011 at 08:53 PM.

  • #2
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,479
    Thanks
    6
    Thanked 981 Times in 954 Posts
    A live example would help tremendously to understand what exactly you mean.


  •  

    Tags for this Thread

    Posting Permissions

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