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

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';



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?

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


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):


or to do all three things at once:

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