javascript - Fade div in and out using the same link onclick -
i can fade div in click how use same click toggle div, i.e. fade div in on click , fade div out on second click.
i'd navbar-toggle clicked once open overlay , clicked again fade out overlay.
<script> $(document).ready(function(e) { $('.navbar-toggle').click(function(e){ $('.overlay, .popup').fadein('slow'); }); $('.navbar-toggle').click(function(e){ $('.overlay, .popup').fadein('slow'); }); }); </script>
you can couple of ways:
solution 1:
use toggle()
$('.navbar-toggle').click(function(e){ $('.overlay, .popup').toggle('fast'); });
solution 2:
use fadetoggle()
$('.navbar-toggle').click(function(e){ $('.overlay, .popup').fadetoggle(300); });
solution 3:
have hidden class , check see if exists
Comments
Post a Comment