Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Simple fadeIn and visibility in jQuery

Tags:

jquery

css

I'm trying to change the css property visibility of a div to visiblewith a jQuery .fadeIn()transition.

Here is my code :

$('a').click(function() {
    $('#test').fadeIn('slow', function() {
     $(this).css('visibility','visible');
  });
});​

and the fiddle : http://jsfiddle.net/np6r7/

like image 682
onimojo Avatar asked Jun 08 '12 01:06

onimojo


People also ask

What is fadeIn in jQuery?

The fadeIn() Method in jQuery is used to change the opacity of selected elements from hidden to visible. The hidden elements will not be display. Syntax: $(selector).fadeIn( speed, easing, callback )

Which of the following method accepts opacity as parameter in jQuery?

The . fadeIn() method animates the opacity of the matched elements.


1 Answers

You cannot animate visibility. fadein is keyed off display:none;, so that should be #test's initial state via CSS. If you need to keep the layout, you can try wrapping test in a div that specifies the height and/or width you need.

like image 71
moribvndvs Avatar answered Sep 19 '22 05:09

moribvndvs