Reputation: 61
I am trying to hide a div on click with no animation. This is my code:
<script>
$('.open-menu').click(function(e){
$('#menulink').fadeOut('fast', function(){
$('#menu, #menu-background').toggle('slide');
});
});
$('#menu-background').click(function(e){
$('#menu, #menu-background').fadeOut('fast', function(){
$('#menulink').fadeIn('fast');
});
});
</script>
The desired action is when you click #menu-background it hides itself with #menu, then #menulink appears again. This I have accomplished, but I want it to hide with no fade or animation. Just to disappear on click. With .hide it still animated and with .fadeOut('0') it still fades.
Any ideas?
Upvotes: 1
Views: 6142
Reputation: 158
How about using css ?
// hide immediately.
$("#hide-me").css("display", "none");
// show immediately.
$("#show-me").css("display", "initial");
Upvotes: 4
Reputation: 350
If you don't want animations, just use .hide() or .show() without parameters instead of fadeout() or fadein().
<script>
$('.open-menu').click(function(e){
$('#menulink').hide();
$('#menu, #menu-background').show();
});
$('#menu-background').click(function(e){
$('#menu, #menu-background').hide();
$('#menulink').show();
});
</script>
Upvotes: 2