// your original image locations
var expand = '/images/plus.png';
var collapse = '/images/minus.png';
// me overwriting them for demo purposes
// my sincere applogies to inbusiness for leeching
expand = 'http://storehandler.inbusiness.com.au/vendita/images/Expand.png'; // ;
collapse = 'http://storehandler.inbusiness.com.au/vendita/images/Expand_Vertical.png'; // ;
// initial setup, we're using bogus images here. (this is only
// needed for the purposes of this demo)
$('.expand').attr({'src':expand,'title':'Expand Selection'});
// Your code, modified
$("a[rel='view-show-info']").click(function() {
// grab the elements we're working with
var anchor = $(this);
var image = $('img',this);
var info = $(this).parent().next('.show-info');
// do the prep work of figuring out image location and text
var image_src = expand;
var image_title = 'expand selection';
if (image.attr("src") == expand) // == "<?=base_url();?>assets/images/plus.png")
{
image_src = collapse;
image_title = 'collapse selection';
}
// now make the changes
info.slideToggle(70);
image.attr({'src':image_src,'alt':image_title});
anchor.attr('title',title);
return false;
});
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.