1

How do I set the values to the callback function, so that it's saved and ready to fire when the element is clicked?

for (i=0; i < ELEMENTS-1; i++) {
    array[i].click(function(){
        array[i].insertAfter(array[i+1]); 
        //other stuff
    });
}

array[] just contains a bunch of divs.

    <div class="wrapper">
        <div id="one" class="tile">One</div>
        <div id="two" class="tile">Two</div>
        <div id="three" class="tile">Three</div>
        <div id="four" class="tile">Four</div>
    </div>

When a div is clicked, I want it to move down the list.

tgun926
  • 1,573
  • 4
  • 21
  • 37

1 Answers1

0

With jQuery, you can use:

$('.wrapper div').click(function() {
    $(this).insertAfter($(this).next());    
});

Fiddle Demo

Felix
  • 37,892
  • 8
  • 43
  • 55