Having trouble with jquery if/else statement and 'slide' effect hiding last element -


this first jquery script i've pieced myself. i'm having issue trying if/else statement working. want script not run if box/link click on visible.

here script working without if statement: http://jsfiddle.net/vitruvius/yqman/

$('.link').click(function () { var parentname = $(this).closest('ul').attr('id'); var boxnumber = $(this).attr('id'); $('.' + parentname).children('.active').toggle('slide',{direction:'right'},function(){     $('.' + parentname + ' ' + 'div').removeclass('active');     $('.' + parentname).children('.' + boxnumber).show().effect('slide').addclass('active'); }); 

});

here attempt @ if statement: http://jsfiddle.net/vitruvius/h8cmu/

$('.link').click(function () { var parentname = $(this).closest('ul').attr('id'); var boxnumber = $(this).attr('id'); if($('.' + parentname).children('.' + boxnumber).hasclass('active')){     return:false; } else {     $('.' + parentname).children('.active').toggle('slide',{direction:'right'},500,function(){         $('.' + parentname + ' ' + 'div').removeclass('active');         $('.' + parentname).children('.' + boxnumber).show().effect('slide').addclass('active');     }); } 

});

also, know why slide effect hides last element before finishes sliding away? couldn't find answer anywhere.

please let me know if have tip and/or suggestions. thanks.

you need replace

return:false; 

by

return false; 

i'd that's enough

demo


Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -

java - Digest auth with Spring Security using javaconfig -