Loading...
Hi,
I
want to change an expand / collapse feature that existed on my site, I would like a simple and similar operation, but for now I get nothing.
Before it is a picture that I change the name of the current source, I would do exactly the same thing but that alternates the background-image.
Here is my current code and the code comment is that before, I would arrive at the same thing in a similar way:
- $.fn.expandCollapse = function() {
$(this).click(function(){
$(this).parent().find('.content').slideToggle("fast");
$(this).find('span').css('background-image', function(i, src) {
return (src.indexOf('expand.png') != -1)? 'tpl/images/collapse.png' :'tpl/images/expand.png';
});
/*
$(this).find('img').attr('src',function(i,src){
return (src.indexOf('expand.png') != -1)? 'tpl/images/collapse.png' :'tpl/images/expand.png';
}); */
});
};
Thank
Replies(1)
I find >
- $(this).find('span').css({'background-image' : function(index, value){
return (value.indexOf('expand.png') != -1)? 'url(tpl/images/collapse.png)' : 'url(tpl/images/expand.png)';
}
});

