Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jquery set html with effect

Tags:

html

jquery

I have a div which is already displaying some html. I'd like to replace the contents of the div with some different html. However, I'd like the transition to have an effect, such as a fade-in.

I've tried this:

$('#mydiv').html('Some new text').fadeIn(1500);

but the transition happens immediately, with no fade effect. Can this be done?

Thanks

like image 649
Journeyman Avatar asked Sep 08 '11 14:09

Journeyman


1 Answers

Try this

$('#mydiv').hide().html('Some new text').fadeIn(1500);
like image 93
ShankarSangoli Avatar answered Sep 22 '22 16:09

ShankarSangoli