Q:

Javascript - Change DIV background on click

I am using JQuery to expand and contract DIV's when an arrow is clicked. The arrow should point up/down depending on if the DIV has been expanded.
I have tried this but doesn't seem to be working. The arrow stays as the default down arrow. The slideup/down works fine, but the image doesn't change. Can anyone explain why?
         function toggle_visibility(id) {
             $e = $("#" + id);
             $arrow = $("#arrow" + id);

             if ($e.is(':visible')){
                 $e.slideUp("slow");
                 $arrow.css('background-image', 'url(../images/downarrow.png)');
             }else{
                $e.slideDown("slow");
                 $arrow.css('background-image', 'url(../images/uparrow.png)');
             }
         }

A:

This should work:  
function toggle_visibility(id) {
         $e = $("#"+id);

         if ($e.is(':visible')){
             $e.slideUp("slow");
             $e.css('background-image', 'url(../images/downarrow.png)');
         }else{
            $e.slideDown("slow");
             $e.css('background-image', 'url(../images/uparrow.png)');
         }
     }

