javascript - Fade element out and fade in data from Array - jQuery -


i have 4 div items on page, i'm trying inner html of these items fade out randomly, take row array , fade in - in place, make sense?

// items repopulate faded out info  var testimonialsarray = [     "<div class='change'><h1>box 5</h1><p>lorem ipsum</p></div>",      "<div class='change'><h1>box 6</h1><p>lorem ipsum</p></div>",      "<div class='change'><h1>box 7</h1><p>lorem ipsum</p></div>",      "<div class='change'><h1>box 8</h1><p>lorem ipsum</p></div>",      "<div class='change'><h1>box 9</h1><p>lorem ipsum</p></div>"  ];  // find random div , fade out  var order = math.floor((math.random()* $('.change').length )+1);  $('.box').eq(order).find('.change').fadeout();  .......fade in new data array row 

http://jsfiddle.net/crn7dysu/1/

based on think wanted do:

var order = math.floor((math.random()* $('.change').length ));  $('.box').eq(order).find('.change').fadeout(function(){    $(this).html(testimonialsarray[math.floor((math.random()* testimonialsarray.length))]).fadein(); }); 

jsfiddle: http://jsfiddle.net/crn7dysu/4/


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -