Change background on expand or collapse

Change background on expand or collapse

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:




  1. $.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