Search code examples
javascriptjqueryhidefadein

jquery Flashes Div Element Before Executing .hide() and .fadeIn() Methods


This is my code:

$('.items').html(response).hide().fadeIn();

The problem is that when this loads, the page "jumps" up due to the element being rendered on page first (having a height) before the .hide().fadeIn() is triggered.. is there some other way to do this?


Solution

  • You could using the opacity instead if you want to keep the dimensions of the element intact:

    $('.items').html(response).css({'opacity':0}).animate({'opacity':1});