Jquery display: name

-5

I need to put display: nome to block the class soon, but, the way I did, it is not working. I was able to put opacity:0 but the display did not catch.

$(document).ready(function(){
    $(".logo").animate({display: 'nome'}, 0);
});
    
asked by anonymous 07.04.2014 / 19:44

2 answers

9

The error is typing and usage.

Replace with:

<script>
    $(document).ready(function() {

        $('.logo').css('display', 'none');

    });
</script>

The jQuery.fn.animate method does not work for the display quer property because it does not exist in the step hooks. And you put "name" instead of none .

You can create a transition so that the element disappears using jQuery.fn.fadeOut like this:

$('.logo').fadeOut(400);

Being 400 is the duration of the effect.

To make appear just use jQuery.fn.fadeIn in the same way.

I think this will solve.

    
07.04.2014 / 19:48
6

You can not animate the display property. Before changing to display none (which you typed wrong), you should animate any other property that makes the element disappear:

  • width or height : animate to 0;

  • opacity : animate to full transparency (note that this will cause an undesirable effect because the space will remain occupied during the animation)

Then after these animations, you can set the display none.

Example:

$('.logo').animate({
     width: 0
   },
   {
     duration: 5000,
     complete: function(){
        $('.logo').hide();
    }
});
    
07.04.2014 / 19:58