Mike Mike - 1 year ago 60
CSS Question

Looping fade between two divs - require modification to answer to this post

The accepted answer to this stackoverflow question is exactly what I need, but with one modification.

I need multiple

. Not just one.

Each "box" has two divs that need to be faded between.

From this snippet of the code:

$(document).ready(function () {
var allBoxes = $("span.boxes").children("span");
transitionBox(null, allBoxes.first());

I understand that I should maybe first, put all the
into an array and then loop over that to get each of their children

But I'm not entirely sure that this is (a) the best practice, (b) correct, and (c) if there is just a better way in the first place.

Answer Source

Do you mean something like this http://jsfiddle.net/8odoros/CYJLA/306/ ?


$( "div.boxes" ).each(function( index ) {
  var allBoxes = $(this).children("div");
  transitionBox(null, allBoxes.first());

applies the same effect to all .boxes