javascript - jQuery Div Toggle Issue -
javascript - jQuery Div Toggle Issue -
live site- http://www.arif-khan.net/other/toggle.html
red bar on left side switch toggle div. problem when click first time doesn't work, subsequent clicks behaves expected. i'm pretty sure because first time hide div show div. need prepare that, on first click show corresponding div instead of hide it.
code-
<script> var speed = 300; $('#close-bar').on('click', function(){ var $$ = $(this); if( $$.is('.hide-bar') ){ $('#togglebox').animate({left:-212}, speed); $$.removeclass('hide-bar') } else { $('#togglebox').animate({left:0}, speed); $$.addclass('hide-bar') } }); </script>
var speed = 300; $('#close-bar').on('click', function () { if ($(this).hasclass('hide-bar')) { $('#togglebox').animate({left:0}, speed); $(this).removeclass('hide-bar'); } else { $('#togglebox').animate({left:-212}, speed); $(this).addclass('hide-bar'); } });
demo
javascript jquery html css
Comments
Post a Comment