<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: jQuery Image Swap Using Click</title>
	<atom:link href="http://www.designchemical.com/blog/index.php/jquery/jquery-image-swap-using-click/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.designchemical.com/blog/index.php/jquery/jquery-image-swap-using-click/</link>
	<description>Your Business Catalyst</description>
	<lastBuildDate>Sat, 04 Feb 2012 05:46:54 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.2</generator>
	<item>
		<title>By: Lee</title>
		<link>http://www.designchemical.com/blog/index.php/jquery/jquery-image-swap-using-click/comment-page-1/#comment-20506</link>
		<dc:creator>Lee</dc:creator>
		<pubDate>Tue, 15 Nov 2011 12:09:42 +0000</pubDate>
		<guid isPermaLink="false">http://www.designchemical.com/blog/?p=834#comment-20506</guid>
		<description>Hi,

It should work with all of the latest versions. None of the core jquery events/functions have changed</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>It should work with all of the latest versions. None of the core jquery events/functions have changed</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sammy</title>
		<link>http://www.designchemical.com/blog/index.php/jquery/jquery-image-swap-using-click/comment-page-1/#comment-17688</link>
		<dc:creator>sammy</dc:creator>
		<pubDate>Fri, 16 Sep 2011 00:52:36 +0000</pubDate>
		<guid isPermaLink="false">http://www.designchemical.com/blog/?p=834#comment-17688</guid>
		<description>wohh perfect! thank you. i guess i was just over complicating it by trying to change the image source to a disabled version.</description>
		<content:encoded><![CDATA[<p>wohh perfect! thank you. i guess i was just over complicating it by trying to change the image source to a disabled version.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Lee</title>
		<link>http://www.designchemical.com/blog/index.php/jquery/jquery-image-swap-using-click/comment-page-1/#comment-17639</link>
		<dc:creator>Lee</dc:creator>
		<pubDate>Thu, 15 Sep 2011 05:23:21 +0000</pubDate>
		<guid isPermaLink="false">http://www.designchemical.com/blog/?p=834#comment-17639</guid>
		<description>Hi,

Can actually be done fairly easily with just a couple of lines of jquery:

[js]
$(&#039;.img-btn.active&#039;).live(&#039;click&#039;,function(){
    $(&#039;.img-btn&#039;).toggleClass(&#039;active&#039;);
    $(&#039;#test&#039;).slideToggle();
});
[/js]

Give the 2 images the class &quot;img-btn&quot; and add class &quot;active&quot; to the close button. See demo - http://www.designchemical.com/lab/jquery/demo/jquery_toggle_buttons.htm</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>Can actually be done fairly easily with just a couple of lines of jquery:</p>
<pre class="brush: jscript; title: ; notranslate">
$('.img-btn.active').live('click',function(){
    $('.img-btn').toggleClass('active');
    $('#test').slideToggle();
});
</pre>
<p>Give the 2 images the class &#8220;img-btn&#8221; and add class &#8220;active&#8221; to the close button. See demo &#8211; <a href="http://www.designchemical.com/lab/jquery/demo/jquery_toggle_buttons.htm" rel="nofollow">http://www.designchemical.com/lab/jquery/demo/jquery_toggle_buttons.htm</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sammy</title>
		<link>http://www.designchemical.com/blog/index.php/jquery/jquery-image-swap-using-click/comment-page-1/#comment-17638</link>
		<dc:creator>sammy</dc:creator>
		<pubDate>Thu, 15 Sep 2011 04:17:33 +0000</pubDate>
		<guid isPermaLink="false">http://www.designchemical.com/blog/?p=834#comment-17638</guid>
		<description>hello, thank for the tut! works great on single button.

i have 2 image buttons, one toggles a div open and the other toggles it closed.
im trying to make it where be default the open button is disabled image, and can&#039;t click it, but then when you click the close button the opposite happens, however im having a real hard time achieving this, i can&#039;t seem to get things figured out.</description>
		<content:encoded><![CDATA[<p>hello, thank for the tut! works great on single button.</p>
<p>i have 2 image buttons, one toggles a div open and the other toggles it closed.<br />
im trying to make it where be default the open button is disabled image, and can&#8217;t click it, but then when you click the close button the opposite happens, however im having a real hard time achieving this, i can&#8217;t seem to get things figured out.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: BG</title>
		<link>http://www.designchemical.com/blog/index.php/jquery/jquery-image-swap-using-click/comment-page-1/#comment-17548</link>
		<dc:creator>BG</dc:creator>
		<pubDate>Tue, 13 Sep 2011 19:32:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.designchemical.com/blog/?p=834#comment-17548</guid>
		<description>red previous comments -- thanks! :) great site.</description>
		<content:encoded><![CDATA[<p>red previous comments &#8212; thanks! <img src='http://www.designchemical.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  great site.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: BG</title>
		<link>http://www.designchemical.com/blog/index.php/jquery/jquery-image-swap-using-click/comment-page-1/#comment-17547</link>
		<dc:creator>BG</dc:creator>
		<pubDate>Tue, 13 Sep 2011 19:15:35 +0000</pubDate>
		<guid isPermaLink="false">http://www.designchemical.com/blog/?p=834#comment-17547</guid>
		<description>great post, almost exactly what i was looking for -- how would i modify this to reset the states of other buttons/images to &quot;off&quot; when one is clicked &quot;on&quot;?</description>
		<content:encoded><![CDATA[<p>great post, almost exactly what i was looking for &#8212; how would i modify this to reset the states of other buttons/images to &#8220;off&#8221; when one is clicked &#8220;on&#8221;?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jay</title>
		<link>http://www.designchemical.com/blog/index.php/jquery/jquery-image-swap-using-click/comment-page-1/#comment-17289</link>
		<dc:creator>Jay</dc:creator>
		<pubDate>Wed, 07 Sep 2011 18:15:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.designchemical.com/blog/?p=834#comment-17289</guid>
		<description>Sorry about that, read the earlier comments and got it working.

Thanks!

Although I have another question.... is it possible to substitute the second swapped image with text?

Thanks again!</description>
		<content:encoded><![CDATA[<p>Sorry about that, read the earlier comments and got it working.</p>
<p>Thanks!</p>
<p>Although I have another question&#8230;. is it possible to substitute the second swapped image with text?</p>
<p>Thanks again!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jay</title>
		<link>http://www.designchemical.com/blog/index.php/jquery/jquery-image-swap-using-click/comment-page-1/#comment-17288</link>
		<dc:creator>Jay</dc:creator>
		<pubDate>Wed, 07 Sep 2011 15:44:24 +0000</pubDate>
		<guid isPermaLink="false">http://www.designchemical.com/blog/?p=834#comment-17288</guid>
		<description>Hey Lee,

Thanks for the cool trick.

I have a scenario that you can possibly look at?

I have a carousel gallery, and for each  I want to add the image swap. if I were to click on an image (image A) and it swapped, is there a way to set up it to if I click on another image (Image B) - then Image A would swap back to the original picture and Image B show its new picture?

Thanks!
Jay</description>
		<content:encoded><![CDATA[<p>Hey Lee,</p>
<p>Thanks for the cool trick.</p>
<p>I have a scenario that you can possibly look at?</p>
<p>I have a carousel gallery, and for each  I want to add the image swap. if I were to click on an image (image A) and it swapped, is there a way to set up it to if I click on another image (Image B) &#8211; then Image A would swap back to the original picture and Image B show its new picture?</p>
<p>Thanks!<br />
Jay</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nick Daugherty</title>
		<link>http://www.designchemical.com/blog/index.php/jquery/jquery-image-swap-using-click/comment-page-1/#comment-17220</link>
		<dc:creator>Nick Daugherty</dc:creator>
		<pubDate>Mon, 05 Sep 2011 14:24:48 +0000</pubDate>
		<guid isPermaLink="false">http://www.designchemical.com/blog/?p=834#comment-17220</guid>
		<description>Brilliant!  Thanks Lee!</description>
		<content:encoded><![CDATA[<p>Brilliant!  Thanks Lee!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Lee</title>
		<link>http://www.designchemical.com/blog/index.php/jquery/jquery-image-swap-using-click/comment-page-1/#comment-17183</link>
		<dc:creator>Lee</dc:creator>
		<pubDate>Sat, 03 Sep 2011 20:59:40 +0000</pubDate>
		<guid isPermaLink="false">http://www.designchemical.com/blog/?p=834#comment-17183</guid>
		<description>Hi,

There are several ways you can do it. A few examples:

1. Load both images in the page and then show/hide based on clicked link

[js]
$(&#039;#book-1 li a&#039;).click(function(e){
		if($(this).hasClass(&#039;version-us&#039;)){
			$(&#039;#book-1 img.version-uk&#039;).fadeOut();
			$(&#039;#book-1 img.version-us&#039;).fadeIn();
		} else {
			$(&#039;#book-1 img.version-uk&#039;).fadeIn();
			$(&#039;#book-1 img.version-us&#039;).fadeOut();
		}
		e.preventDefault();
	});
[/js]

2. Change the image using the &quot;href&quot; attribute of the link to switch the &quot;src&quot; value of the image

[js]
$(&#039;#book-2 li a&#039;).click(function(e){
		var src = $(this).attr(&#039;href&#039;);
		$(&#039;.book-version&#039;).attr(&#039;src&#039;,src);
		e.preventDefault();
	});
[/js]

I think AJAX is maybe a bit of an overkill unless you need to dynamically generate the image in PHP and it cannot be done prior to loading the page. In this case though you cant call the pHP function directly in the jQuery code - you need to do an AJAX POST to a file, which then runs the function.

The function will return a value (e.g. the image HTML), which can then be used by jQuery to swap the images

[js]
$(&#039;#book-3 li a&#039;).click(function(e){
                // In this example we pass a variable using the rel attribute of the link.
		var rel = $(this).attr(&#039;rel&#039;);

                // AJAX POST - url of PHP file, any parameters you need to pass then finish off with the callback function if successful
		$.post(&#039;image_function.php&#039;, ({version: rel}),function(data){
			$(&#039;#book-3 img&#039;).fadeOut().remove();
			$(&#039;#book-3&#039;).append(data);
		});
		e.preventDefault();
	});
[/js]

There are probably many other ways but this should hopefully give an idea of what kind of things you can do.

I have set up a demo page at the link below so you can also see the source code for each:

&lt;a href=&quot;/lab/jquery/demo/jquery_image_swap_ajax.htm&quot; rel=&quot;nofollow&quot;&gt;Jquery Demo - Change Image onclick&lt;/a&gt;</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>There are several ways you can do it. A few examples:</p>
<p>1. Load both images in the page and then show/hide based on clicked link</p>
<pre class="brush: jscript; title: ; notranslate">
$('#book-1 li a').click(function(e){
		if($(this).hasClass('version-us')){
			$('#book-1 img.version-uk').fadeOut();
			$('#book-1 img.version-us').fadeIn();
		} else {
			$('#book-1 img.version-uk').fadeIn();
			$('#book-1 img.version-us').fadeOut();
		}
		e.preventDefault();
	});
</pre>
<p>2. Change the image using the &#8220;href&#8221; attribute of the link to switch the &#8220;src&#8221; value of the image</p>
<pre class="brush: jscript; title: ; notranslate">
$('#book-2 li a').click(function(e){
		var src = $(this).attr('href');
		$('.book-version').attr('src',src);
		e.preventDefault();
	});
</pre>
<p>I think AJAX is maybe a bit of an overkill unless you need to dynamically generate the image in PHP and it cannot be done prior to loading the page. In this case though you cant call the pHP function directly in the jQuery code &#8211; you need to do an AJAX POST to a file, which then runs the function.</p>
<p>The function will return a value (e.g. the image HTML), which can then be used by jQuery to swap the images</p>
<pre class="brush: jscript; title: ; notranslate">
$('#book-3 li a').click(function(e){
                // In this example we pass a variable using the rel attribute of the link.
		var rel = $(this).attr('rel');

                // AJAX POST - url of PHP file, any parameters you need to pass then finish off with the callback function if successful
		$.post('image_function.php', ({version: rel}),function(data){
			$('#book-3 img').fadeOut().remove();
			$('#book-3').append(data);
		});
		e.preventDefault();
	});
</pre>
<p>There are probably many other ways but this should hopefully give an idea of what kind of things you can do.</p>
<p>I have set up a demo page at the link below so you can also see the source code for each:</p>
<p><a href="/lab/jquery/demo/jquery_image_swap_ajax.htm" rel="nofollow">Jquery Demo &#8211; Change Image onclick</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nick Daugherty</title>
		<link>http://www.designchemical.com/blog/index.php/jquery/jquery-image-swap-using-click/comment-page-1/#comment-17182</link>
		<dc:creator>Nick Daugherty</dc:creator>
		<pubDate>Sat, 03 Sep 2011 19:36:52 +0000</pubDate>
		<guid isPermaLink="false">http://www.designchemical.com/blog/?p=834#comment-17182</guid>
		<description>Hi Lee,

Thanks for your post.  I have a similar scenario that I can&#039;t quite figure out... 

I&#039;m working on a WordPress site which shows a list of books -- and each book has 2 covers (a book cover for the US, and a different book cover for the UK/world).

I have a DIV with 2 links (US Version and UK Version) -- and I&#039;m trying to use jQuery and/or Ajax to switch the cover when you click on each link.

Here&#039;s a screenshot: http://cl.ly/2W1U1j2k1c1S3q0g3w2m

I&#039;m getting stuck because I need to call the image using a PHP function, let&#039;s call it &quot;get_image&quot;

Here&#039;s my code.  Can you help?
HTML:
[text]&lt;a id=&quot;us-cover&quot; href=&quot;#&quot;&gt;US Version&lt;/a&gt; &#124; &lt;a id=&quot;uk-cover&quot;href=&quot;#&quot;&gt;UK Version&lt;/a&gt;[/text]

JAVASCRIPT:
[text]jQuery(function(){
	 $(&quot;#us-cover&quot;).live(&#039;click&#039;, function() {
		&lt;?php get_image(&#039;us&#039;); ?&gt;
	});
jQuery(function(){
	 $(&quot;#uk-cover&quot;).live(&#039;click&#039;, function() {
		&lt;?php get_image(&#039;uk&#039;); ?&gt;
	});
});
});[/text]</description>
		<content:encoded><![CDATA[<p>Hi Lee,</p>
<p>Thanks for your post.  I have a similar scenario that I can&#8217;t quite figure out&#8230; </p>
<p>I&#8217;m working on a WordPress site which shows a list of books &#8212; and each book has 2 covers (a book cover for the US, and a different book cover for the UK/world).</p>
<p>I have a DIV with 2 links (US Version and UK Version) &#8212; and I&#8217;m trying to use jQuery and/or Ajax to switch the cover when you click on each link.</p>
<p>Here&#8217;s a screenshot: <a href="http://cl.ly/2W1U1j2k1c1S3q0g3w2m" rel="nofollow">http://cl.ly/2W1U1j2k1c1S3q0g3w2m</a></p>
<p>I&#8217;m getting stuck because I need to call the image using a PHP function, let&#8217;s call it &#8220;get_image&#8221;</p>
<p>Here&#8217;s my code.  Can you help?<br />
HTML:</p>
<pre class="brush: plain; title: ; notranslate">&lt;a id=&quot;us-cover&quot; href=&quot;#&quot;&gt;US Version&lt;/a&gt; | &lt;a id=&quot;uk-cover&quot;href=&quot;#&quot;&gt;UK Version&lt;/a&gt;</pre>
<p>JAVASCRIPT:</p>
<pre class="brush: plain; title: ; notranslate">jQuery(function(){
	 $(&quot;#us-cover&quot;).live('click', function() {
		&lt;?php get_image('us'); ?&gt;
	});
jQuery(function(){
	 $(&quot;#uk-cover&quot;).live('click', function() {
		&lt;?php get_image('uk'); ?&gt;
	});
});
});</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Lee</title>
		<link>http://www.designchemical.com/blog/index.php/jquery/jquery-image-swap-using-click/comment-page-1/#comment-14048</link>
		<dc:creator>Lee</dc:creator>
		<pubDate>Thu, 09 Jun 2011 17:20:31 +0000</pubDate>
		<guid isPermaLink="false">http://www.designchemical.com/blog/?p=834#comment-14048</guid>
		<description>Hi - the concept is exactly the same - just add the image swap class to each menu item</description>
		<content:encoded><![CDATA[<p>Hi &#8211; the concept is exactly the same &#8211; just add the image swap class to each menu item</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: David</title>
		<link>http://www.designchemical.com/blog/index.php/jquery/jquery-image-swap-using-click/comment-page-1/#comment-14022</link>
		<dc:creator>David</dc:creator>
		<pubDate>Wed, 08 Jun 2011 14:32:44 +0000</pubDate>
		<guid isPermaLink="false">http://www.designchemical.com/blog/?p=834#comment-14022</guid>
		<description>Hi, can you post a menu swap image onclick working example. thanks.</description>
		<content:encoded><![CDATA[<p>Hi, can you post a menu swap image onclick working example. thanks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Lee</title>
		<link>http://www.designchemical.com/blog/index.php/jquery/jquery-image-swap-using-click/comment-page-1/#comment-13949</link>
		<dc:creator>Lee</dc:creator>
		<pubDate>Mon, 06 Jun 2011 15:42:29 +0000</pubDate>
		<guid isPermaLink="false">http://www.designchemical.com/blog/?p=834#comment-13949</guid>
		<description>Hi John,

You can use the following jQuery code:

[js]
$(function(){
	$(&quot;#btn-swap&quot;).click(function(){
		$(&#039;.img-swap&#039;).each(function(){
			if($(this).hasClass(&#039;on&#039;)){
				this.src = this.src.replace(&quot;_on&quot;,&quot;_off&quot;);
			} else {
				this.src = this.src.replace(&quot;_off&quot;,&quot;_on&quot;);
			}
			$(this).toggleClass(&quot;on&quot;);
		});
	});
});
[/js]

All you then need to do is give the button/link that you want to use to toggle the image states an ID of &quot;btn-swap&quot;.

When clicked this will change any image that has the class &quot;img-swap&quot;. I have uploaded a demo page - &lt;a href=&quot;/lab/jquery/demo/jquery_demo_multiple_image_swap_onclick.htm&quot; rel=&quot;nofollow&quot;&gt;jQuery Demo: Multiple Image Swap On Click Button&lt;/a&gt;</description>
		<content:encoded><![CDATA[<p>Hi John,</p>
<p>You can use the following jQuery code:</p>
<pre class="brush: jscript; title: ; notranslate">
$(function(){
	$(&quot;#btn-swap&quot;).click(function(){
		$('.img-swap').each(function(){
			if($(this).hasClass('on')){
				this.src = this.src.replace(&quot;_on&quot;,&quot;_off&quot;);
			} else {
				this.src = this.src.replace(&quot;_off&quot;,&quot;_on&quot;);
			}
			$(this).toggleClass(&quot;on&quot;);
		});
	});
});
</pre>
<p>All you then need to do is give the button/link that you want to use to toggle the image states an ID of &#8220;btn-swap&#8221;.</p>
<p>When clicked this will change any image that has the class &#8220;img-swap&#8221;. I have uploaded a demo page &#8211; <a href="/lab/jquery/demo/jquery_demo_multiple_image_swap_onclick.htm" rel="nofollow">jQuery Demo: Multiple Image Swap On Click Button</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John Marcotte</title>
		<link>http://www.designchemical.com/blog/index.php/jquery/jquery-image-swap-using-click/comment-page-1/#comment-13948</link>
		<dc:creator>John Marcotte</dc:creator>
		<pubDate>Mon, 06 Jun 2011 15:05:18 +0000</pubDate>
		<guid isPermaLink="false">http://www.designchemical.com/blog/?p=834#comment-13948</guid>
		<description>Lee,

This helps solve a problem I was having at work, however, I also need a button to change the states of all my buttons &quot;on&quot; and &quot;off.&quot;

Since I have virtually zero programming skills, I was hoping you could point me in the right direction to accomplish that effect.</description>
		<content:encoded><![CDATA[<p>Lee,</p>
<p>This helps solve a problem I was having at work, however, I also need a button to change the states of all my buttons &#8220;on&#8221; and &#8220;off.&#8221;</p>
<p>Since I have virtually zero programming skills, I was hoping you could point me in the right direction to accomplish that effect.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rob</title>
		<link>http://www.designchemical.com/blog/index.php/jquery/jquery-image-swap-using-click/comment-page-1/#comment-12199</link>
		<dc:creator>Rob</dc:creator>
		<pubDate>Thu, 28 Apr 2011 07:18:14 +0000</pubDate>
		<guid isPermaLink="false">http://www.designchemical.com/blog/?p=834#comment-12199</guid>
		<description>Awesome Les.  You are a life saver.

This blog is great too.  Lots of great tutorials!</description>
		<content:encoded><![CDATA[<p>Awesome Les.  You are a life saver.</p>
<p>This blog is great too.  Lots of great tutorials!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Lee</title>
		<link>http://www.designchemical.com/blog/index.php/jquery/jquery-image-swap-using-click/comment-page-1/#comment-12195</link>
		<dc:creator>Lee</dc:creator>
		<pubDate>Thu, 28 Apr 2011 01:44:33 +0000</pubDate>
		<guid isPermaLink="false">http://www.designchemical.com/blog/?p=834#comment-12195</guid>
		<description>Rob - you need to remove the first hover event. Only use the one I gave earlier</description>
		<content:encoded><![CDATA[<p>Rob &#8211; you need to remove the first hover event. Only use the one I gave earlier</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rob</title>
		<link>http://www.designchemical.com/blog/index.php/jquery/jquery-image-swap-using-click/comment-page-1/#comment-12189</link>
		<dc:creator>Rob</dc:creator>
		<pubDate>Wed, 27 Apr 2011 21:13:53 +0000</pubDate>
		<guid isPermaLink="false">http://www.designchemical.com/blog/?p=834#comment-12189</guid>
		<description>Les, once again, thank you for the reply.  I tried out what you put up here straight up like you presented it to me and still nothing.  My roll overs are back and working but the swap onclick is not.

Any thoughts?</description>
		<content:encoded><![CDATA[<p>Les, once again, thank you for the reply.  I tried out what you put up here straight up like you presented it to me and still nothing.  My roll overs are back and working but the swap onclick is not.</p>
<p>Any thoughts?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Lee</title>
		<link>http://www.designchemical.com/blog/index.php/jquery/jquery-image-swap-using-click/comment-page-1/#comment-12176</link>
		<dc:creator>Lee</dc:creator>
		<pubDate>Wed, 27 Apr 2011 05:23:47 +0000</pubDate>
		<guid isPermaLink="false">http://www.designchemical.com/blog/?p=834#comment-12176</guid>
		<description>Hi Rob - Sorry I just realised I copy/pasted the wrong code from a different file in my earlier reply.

Use the following instead:

[js]
$(&quot;.img-swap:not(.active)&quot;).hover(
    function(){this.src = this.src.replace(&quot;_off&quot;,&quot;_on&quot;);},
    function(){
        if(!$(this).hasClass(&#039;active&#039;)){
            this.src = this.src.replace(&quot;_on&quot;,&quot;_off&quot;);
        }
    });
	$(&quot;.img-swap&quot;).click(function(){
		$(&quot;.img-swap.active&quot;).each(function(){
			this.src = this.src.replace(&quot;_on&quot;,&quot;_off&quot;);
			$(this).removeClass(&#039;active&#039;);
		});
	$(this).toggleClass(&#039;active&#039;);
	});
[/js]</description>
		<content:encoded><![CDATA[<p>Hi Rob &#8211; Sorry I just realised I copy/pasted the wrong code from a different file in my earlier reply.</p>
<p>Use the following instead:</p>
<pre class="brush: jscript; title: ; notranslate">
$(&quot;.img-swap:not(.active)&quot;).hover(
    function(){this.src = this.src.replace(&quot;_off&quot;,&quot;_on&quot;);},
    function(){
        if(!$(this).hasClass('active')){
            this.src = this.src.replace(&quot;_on&quot;,&quot;_off&quot;);
        }
    });
	$(&quot;.img-swap&quot;).click(function(){
		$(&quot;.img-swap.active&quot;).each(function(){
			this.src = this.src.replace(&quot;_on&quot;,&quot;_off&quot;);
			$(this).removeClass('active');
		});
	$(this).toggleClass('active');
	});
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rob</title>
		<link>http://www.designchemical.com/blog/index.php/jquery/jquery-image-swap-using-click/comment-page-1/#comment-12174</link>
		<dc:creator>Rob</dc:creator>
		<pubDate>Wed, 27 Apr 2011 04:14:22 +0000</pubDate>
		<guid isPermaLink="false">http://www.designchemical.com/blog/?p=834#comment-12174</guid>
		<description>Thanks for the response Lee.  I am just not quite getting it though.  I tried your code and it does not seem to work.  I have none of this defined in the CSS if that makes any difference since these are images and no styling is needed.

I just want these images to swap on click and mouse over.  I am not that great with understanding the jQuery.

I slightly modified your code and I am getting something to happen with the hovers and clicks but the clicks are off a bit.  Hit a few links and let me know what you think.

I really appreciate the help.</description>
		<content:encoded><![CDATA[<p>Thanks for the response Lee.  I am just not quite getting it though.  I tried your code and it does not seem to work.  I have none of this defined in the CSS if that makes any difference since these are images and no styling is needed.</p>
<p>I just want these images to swap on click and mouse over.  I am not that great with understanding the jQuery.</p>
<p>I slightly modified your code and I am getting something to happen with the hovers and clicks but the clicks are off a bit.  Hit a few links and let me know what you think.</p>
<p>I really appreciate the help.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Lee</title>
		<link>http://www.designchemical.com/blog/index.php/jquery/jquery-image-swap-using-click/comment-page-1/#comment-12150</link>
		<dc:creator>Lee</dc:creator>
		<pubDate>Tue, 26 Apr 2011 21:08:45 +0000</pubDate>
		<guid isPermaLink="false">http://www.designchemical.com/blog/?p=834#comment-12150</guid>
		<description>James - it sounds like the image does not have the &#039;active&#039; class so it will follow the mouseout event, which is the only part of the code that is able to replace &quot;_on&quot; with &quot;_off&quot;

Check in firebug whether the image has class &quot;active&quot; after clicking</description>
		<content:encoded><![CDATA[<p>James &#8211; it sounds like the image does not have the &#8216;active&#8217; class so it will follow the mouseout event, which is the only part of the code that is able to replace &#8220;_on&#8221; with &#8220;_off&#8221;</p>
<p>Check in firebug whether the image has class &#8220;active&#8221; after clicking</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: James</title>
		<link>http://www.designchemical.com/blog/index.php/jquery/jquery-image-swap-using-click/comment-page-1/#comment-12140</link>
		<dc:creator>James</dc:creator>
		<pubDate>Tue, 26 Apr 2011 19:36:08 +0000</pubDate>
		<guid isPermaLink="false">http://www.designchemical.com/blog/?p=834#comment-12140</guid>
		<description>Thanks for the quick response... can&#039;t seem to get this one working. It hovers ok, but the onclick takes you to the off image not the on one...</description>
		<content:encoded><![CDATA[<p>Thanks for the quick response&#8230; can&#8217;t seem to get this one working. It hovers ok, but the onclick takes you to the off image not the on one&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Lee</title>
		<link>http://www.designchemical.com/blog/index.php/jquery/jquery-image-swap-using-click/comment-page-1/#comment-12137</link>
		<dc:creator>Lee</dc:creator>
		<pubDate>Tue, 26 Apr 2011 19:10:27 +0000</pubDate>
		<guid isPermaLink="false">http://www.designchemical.com/blog/?p=834#comment-12137</guid>
		<description>James - see earlier comment</description>
		<content:encoded><![CDATA[<p>James &#8211; see earlier comment</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: James</title>
		<link>http://www.designchemical.com/blog/index.php/jquery/jquery-image-swap-using-click/comment-page-1/#comment-12136</link>
		<dc:creator>James</dc:creator>
		<pubDate>Tue, 26 Apr 2011 18:57:15 +0000</pubDate>
		<guid isPermaLink="false">http://www.designchemical.com/blog/?p=834#comment-12136</guid>
		<description>Hi, did anyone have an answer to JW regarding resetting all the images if another image is clicked. Like a radio button would.. I&#039;m fairly new to jQuery and can&#039;t seem to work it out... thanks</description>
		<content:encoded><![CDATA[<p>Hi, did anyone have an answer to JW regarding resetting all the images if another image is clicked. Like a radio button would.. I&#8217;m fairly new to jQuery and can&#8217;t seem to work it out&#8230; thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Lee</title>
		<link>http://www.designchemical.com/blog/index.php/jquery/jquery-image-swap-using-click/comment-page-1/#comment-12133</link>
		<dc:creator>Lee</dc:creator>
		<pubDate>Tue, 26 Apr 2011 18:46:33 +0000</pubDate>
		<guid isPermaLink="false">http://www.designchemical.com/blog/?p=834#comment-12133</guid>
		<description>Hi Rob - probably not the most elegant solution but this should work:

[js]
$(&quot;.img-swap:not(.active)&quot;).hover(
    function(){
        this.src = this.src.replace(&quot;_off&quot;,&quot;_on&quot;);
    },
    function(){
        this.src = this.src.replace(&quot;_on&quot;,&quot;_off&quot;);
    });
    $(&quot;.img-swap&quot;).click(function(){
        $(&quot;.img-swap.active&quot;).each(function(){
            this.src = this.src.replace(&quot;_on&quot;,&quot;_off&quot;);
            $(this).removeClass(&#039;active&#039;);
        });
         $(this).toggleClass(&#039;active&#039;);
    });
[/js]</description>
		<content:encoded><![CDATA[<p>Hi Rob &#8211; probably not the most elegant solution but this should work:</p>
<pre class="brush: jscript; title: ; notranslate">
$(&quot;.img-swap:not(.active)&quot;).hover(
    function(){
        this.src = this.src.replace(&quot;_off&quot;,&quot;_on&quot;);
    },
    function(){
        this.src = this.src.replace(&quot;_on&quot;,&quot;_off&quot;);
    });
    $(&quot;.img-swap&quot;).click(function(){
        $(&quot;.img-swap.active&quot;).each(function(){
            this.src = this.src.replace(&quot;_on&quot;,&quot;_off&quot;);
            $(this).removeClass('active');
        });
         $(this).toggleClass('active');
    });
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rob</title>
		<link>http://www.designchemical.com/blog/index.php/jquery/jquery-image-swap-using-click/comment-page-1/#comment-12128</link>
		<dc:creator>Rob</dc:creator>
		<pubDate>Tue, 26 Apr 2011 16:21:08 +0000</pubDate>
		<guid isPermaLink="false">http://www.designchemical.com/blog/?p=834#comment-12128</guid>
		<description>This is great, I used the image swap on hover and it works perfectly.  I am trying to get this to work with a click also but cannot seem to get it working.  Can anyone see what I am doing wrong?

&lt;a href=&quot;http://bridgfordfoodservice.net/ready_to_eat/products.php&quot; rel=&quot;nofollow&quot;&gt;http://bridgfordfoodservice.net/ready_to_eat/products.php&lt;/a&gt;

It is suppose to work on the left hand menu that changes the product.  You can see that it hovers but does no stay when the link is clicked.</description>
		<content:encoded><![CDATA[<p>This is great, I used the image swap on hover and it works perfectly.  I am trying to get this to work with a click also but cannot seem to get it working.  Can anyone see what I am doing wrong?</p>
<p><a href="http://bridgfordfoodservice.net/ready_to_eat/products.php" rel="nofollow">http://bridgfordfoodservice.net/ready_to_eat/products.php</a></p>
<p>It is suppose to work on the left hand menu that changes the product.  You can see that it hovers but does no stay when the link is clicked.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Lee</title>
		<link>http://www.designchemical.com/blog/index.php/jquery/jquery-image-swap-using-click/comment-page-1/#comment-11846</link>
		<dc:creator>Lee</dc:creator>
		<pubDate>Wed, 20 Apr 2011 21:35:22 +0000</pubDate>
		<guid isPermaLink="false">http://www.designchemical.com/blog/?p=834#comment-11846</guid>
		<description>Hi Kundra - just add the following CSS to your style sheet:

[text]
.img-swap {cursor: pointer;}
[/text]

&lt;a href=&quot;/lab/jquery/demo/jquery_image_swap_click.htm&quot; rel=&quot;nofollow&quot;&gt;Can see it working on the demo&lt;/a&gt;</description>
		<content:encoded><![CDATA[<p>Hi Kundra &#8211; just add the following CSS to your style sheet:</p>
<pre class="brush: plain; title: ; notranslate">
.img-swap {cursor: pointer;}
</pre>
<p><a href="/lab/jquery/demo/jquery_image_swap_click.htm" rel="nofollow">Can see it working on the demo</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: kundra</title>
		<link>http://www.designchemical.com/blog/index.php/jquery/jquery-image-swap-using-click/comment-page-1/#comment-11845</link>
		<dc:creator>kundra</dc:creator>
		<pubDate>Wed, 20 Apr 2011 21:12:29 +0000</pubDate>
		<guid isPermaLink="false">http://www.designchemical.com/blog/?p=834#comment-11845</guid>
		<description>Works great - than kyou so much! Just one question, is there a way to turn the cursor into a pointer on mouseover? How would you do that in JQuery? Thanks a lot!</description>
		<content:encoded><![CDATA[<p>Works great &#8211; than kyou so much! Just one question, is there a way to turn the cursor into a pointer on mouseover? How would you do that in JQuery? Thanks a lot!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Lee</title>
		<link>http://www.designchemical.com/blog/index.php/jquery/jquery-image-swap-using-click/comment-page-1/#comment-10454</link>
		<dc:creator>Lee</dc:creator>
		<pubDate>Sat, 26 Mar 2011 17:44:52 +0000</pubDate>
		<guid isPermaLink="false">http://www.designchemical.com/blog/?p=834#comment-10454</guid>
		<description>James - nothing required server-side. You do need the jQuery library loading first though. Make sure the following code is included in the head of the document before the jQuery code:

[js]
&lt;script type=&quot;text/javascript&quot; src=&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js&quot;&gt;&lt;/script&gt;
[/js]</description>
		<content:encoded><![CDATA[<p>James &#8211; nothing required server-side. You do need the jQuery library loading first though. Make sure the following code is included in the head of the document before the jQuery code:</p>
<pre class="brush: jscript; title: ; notranslate">
&lt;script type=&quot;text/javascript&quot; src=&quot;<a href="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js&quot;&gt;&lt;/script&#038;gt" rel="nofollow">http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js&quot;&gt;&lt;/script&#038;gt</a>;
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: James</title>
		<link>http://www.designchemical.com/blog/index.php/jquery/jquery-image-swap-using-click/comment-page-1/#comment-10453</link>
		<dc:creator>James</dc:creator>
		<pubDate>Sat, 26 Mar 2011 17:29:24 +0000</pubDate>
		<guid isPermaLink="false">http://www.designchemical.com/blog/?p=834#comment-10453</guid>
		<description>Is there something I need server side for this to work?  I can&#039;t seem to get this to work when I test this locally.

btw, I&#039;ve never used js or jquery before so I may be missing something basic</description>
		<content:encoded><![CDATA[<p>Is there something I need server side for this to work?  I can&#8217;t seem to get this to work when I test this locally.</p>
<p>btw, I&#8217;ve never used js or jquery before so I may be missing something basic</p>
]]></content:encoded>
	</item>
</channel>
</rss>

