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

Popular posts from this blog

delphi - How to convert bitmaps to video? -

jasper reports - Fixed header in Excel using JasperReports -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -