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.
Comments
Post a Comment