PDA

View Full Version : Can't add .fadeIn effect (jQuery)



viens
09-24-2009, 10:07 AM
Any jQuery experts here?


if(msg == "OK")
{
result = '<img src="/images/sent.png"><br />Your message has been sent';

$("#fields").hide();
$(this).html(result);

}

I spent several hours trying to add .fadeIn effect to the result so that result doesn't appear immediately, but fades in. No success. Can somebody help?

jscheuer1
09-27-2009, 04:09 PM
Well, according to the jQuery documentation page on this effect:

http://docs.jquery.com/Effects/fadeIn

it can be deduced that the thing you are fading in should be hidden (display: none;). Assuming from your code that 'this' refers to the element that contains the result, make it display none first. Then you can (addition highlighted):


$(this).html(result).fadeIn('slow');

or to do all three things at once:


$(this).css('display', 'none').html(result).fadeIn('slow');