novactown
novactown

Reputation: 137

Jquery to fade in .after()?

Simple really but cannot get it to work, here is my script...

$('body').after('<div id="lightBox" style="height: ' + htmlHeight + 'px;"></div>');

How can I get it to fade in rather than just pop up? putting fadeIn() after or before .after() doesn't work?

Upvotes: 8

Views: 8617

Answers (3)

directory
directory

Reputation: 3167

Short way:

$('body').after($('<div id="lightBox" style="height: ' + htmlHeight + 'px;"></div>').hide().fadeIn());

Upvotes: 2

genesis
genesis

Reputation: 50974

$('body').after('<div id="lightBox" style="height: ' + htmlHeight + 'px;"></div>');  
$("#lightBox").hide().fadeIn();

It hides it and then fades in

Upvotes: 3

David Tran
David Tran

Reputation: 10626

$('body').after('<div id="lightBox" style="height: ' + htmlHeight + 'px; display:none;"></div>');
$('#lightBox').fadeIn();

Upvotes: 4

Related Questions