Go Back   CodingForums.com > :: Client side development > JavaScript programming > JavaScript frameworks

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-18-2009, 10:12 PM   PM User | #1
l0rdQuas
New to the CF scene

 
Join Date: Feb 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
l0rdQuas is an unknown quantity at this point
Javascript - switch DIV content

Hi

hopefully I can get the answer I need here, or any help with it will be much appriacted.

What I'm trying to do is switch the content of a div on the click of an image [button] the div in question holds the images to a jQuery zoom function[class="zoom"]. I'd like to change the images that are used on a button click.

heres a snippet of the code:

Quote:
<div id="image">
<a href="images/image1.gif" class="zoom">
<img src="images/images1Large.gif"/>
</a>
</div>
<div id="button">
<img src="images/image1button.gif"/>
<img src="images/image2button.gif"/>
</div>
I'd like to be able to switch the (id)image div to contain:
Quote:
<a href="images/image2.gif" class="zoom">
<img src="images/images2Large.gif"/>
</a>
onClick of img=image2button

Hope this makes sense, and thanks in advance for any help and suggestions

Cheers,

LQ
l0rdQuas is offline   Reply With Quote
Old 02-26-2009, 06:00 PM   PM User | #2
Eldarrion
Regular Coder

 
Join Date: Feb 2009
Location: Wheeling, IL
Posts: 358
Thanks: 5
Thanked 62 Times in 60 Posts
Eldarrion is on a distinguished road
Here is the function you need to add to your javascript:
Code:
function imgclick() {
        $("#image").html("<a href=\"images/image2.gif\" class=\"zoom\"><img src=\"images/images2Large.gif\"/></a>");
    };
And of course

Code:
<img src="images/image2button.gif" onclick="imgclick()"/>
That should do the trick. Do let me know if it doesn't and I'll look into solving the problem.
Eldarrion is offline   Reply With Quote
Reply

Bookmarks

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:05 AM.


Advertisement
Log in to turn off these ads.