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 to the CF scene
    Join Date
    Apr 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Angry Swap Image and JS link onclick

    NOOB Alert! - So after two days of searching, trying and smashing things while my manager breathes down my neck for a result, I'm forced to plead for help with this:

    I'm doing a multiple animated div page where i'd like to have a simple image with rollover effect. I'm using jquery as well.

    The initial onclick would be a call to hide a specific group of id's. I have this working with the following:

    Code:
    <a href="javascript:animatedcollapse.show(unique_group_of_IDs)"><img src="sample_state1.png"></a>
    and to hide:

    Code:
    <a href="javascript:animatedcollapse.hide(unique_group_of_IDs)"><img src="sample_state2.png"></a>
    So! The question is how can I have one image/image rollover and link call to that js command and then swap to another image/image rollover and link while staying on the same page?

    Thanks, I'm stuck and desperate and have looked everywhere (i think) :S.

  • #2
    Senior Coder
    Join Date
    Jul 2009
    Location
    South Yorkshire, England
    Posts
    2,318
    Thanks
    6
    Thanked 304 Times in 303 Posts
    Something like this, if I recall correctly.

    Code:
    <img id="sample_state" src="sample_state1.png">
    Then, in your function:

    Code:
    if (getElementById('sample_state').src == 'sample_state2.png')
    {
        getElementById('sample_state').src =  'sample_state1.png';
    }
    else
    {
        getElementById('sample_state').src =  'sample_state2.png';
    }

  • #3
    New to the CF scene
    Join Date
    Apr 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks for the reply Matt! How do I swap out the links? Sorry if it's obvious to you but I'm stumped.

  • #4
    New to the CF scene
    Join Date
    Apr 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    does anyone know how to make the links dynamic as well? thanks.


  •  

    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
    •