View Single Post
Old 08-18-2009, 08:47 AM   #13 (permalink)
sketchMedia
The Prestige
Advanced Programmer Top Contributor Good Samaritan 
 
sketchMedia's Avatar
 
Join Date: Oct 2007
Location: Manchester, UK
Posts: 854
Thanks: 32
sketchMedia is on a distinguished road
Default

try this, instead of toggle:
javascript Code:
$('div.boxtop').click(function(){
        c = $('~div.boxcontent', this);
        if($(c).css('display') !== 'block'){
            $(this).css("background-image","url(images/boxtop_close.gif)");
            $(c).slideDown('fast');
        }else{
            $(this).css("background-image","url(images/boxtop_open.gif)");
            $(c).slideUp('fast');
        }
    });

The problem with the toggle switch is that it only does one thing then the other however if you need it to be more intelligent (i.e. figure out what state it currently has, and do handle the event accordingly) its alot easier just to use a single click event and conditionally handle it.
__________________
mysql> SELECT * FROM `users` WHERE `users`.`clue` > 0;
Empty set (0.00 sec)
sketchMedia is offline  
Reply With Quote