fadein - how to fade in newly added div with jquery? -
i have item comes in dom inside div
.
i trying add item fading in, , took approach. doesn't seem work
<div id="messages" class="comm"> <div class="message">00:50:09</div> <div class="message">00:50:04</div> <div class="message">00:49:04</div> </div> var out = ''; out += '<div class="curent">testingg</div>'; $('.comm').prepend(out); $('.messages').css({'opacity':'1'}); $('.curent').removeclass('messages').addclass('message'); .messages{ opacity: 0; }
u can see code in jsfiddle also.
any ideas?
thanlks
how this:
$('.curent').hide().fadein();
setting opacity 1 or value doesn't cause fade because changes old value new value. can use .animate()
method fade between old , new opacities, jquery has .fadein() method
you. .hide()
element before calling .fadein()
.
note changing same property several times within same code block not result in animation user can see because whole block execute before browser refreshes page. .removeclass('messages').addclass('message')
has no noticeable effect unless element(s) didn't have 'messages' class begin with. need use settimeout()
based animation (which jquery's animation effects methods use) browser gets chance refresh page in between property changes.
Comments
Post a Comment