Go Back   CodingForums.com > :: Client side development > JavaScript programming > DOM and JSON scripting

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rating: Thread Rating: 2 votes, 4.50 average.
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 04-16-2010, 07:29 PM   PM User | #1
mmic
New to the CF scene

 
Join Date: Apr 2010
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
mmic is an unknown quantity at this point
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.
mmic is offline   Reply With Quote
Old 04-16-2010, 07:37 PM   PM User | #2
MattF
Senior Coder

 
Join Date: Jul 2009
Location: South Yorkshire, England
Posts: 2,322
Thanks: 6
Thanked 304 Times in 303 Posts
MattF will become famous soon enoughMattF will become famous soon enough
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';
}
MattF is offline   Reply With Quote
Old 04-16-2010, 08:00 PM   PM User | #3
mmic
New to the CF scene

 
Join Date: Apr 2010
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
mmic is an unknown quantity at this point
Thanks for the reply Matt! How do I swap out the links? Sorry if it's obvious to you but I'm stumped.
mmic is offline   Reply With Quote
Old 04-19-2010, 05:01 PM   PM User | #4
mmic
New to the CF scene

 
Join Date: Apr 2010
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
mmic is an unknown quantity at this point
does anyone know how to make the links dynamic as well? thanks.
mmic is offline   Reply With Quote
Reply

Bookmarks

Tags
collapse, div, image, jquery, swap

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 10:27 PM.


Advertisement
Log in to turn off these ads.