javascript - Slide div element to another element JQuery -
i have array grid contains . how how create
grid[row][col] = $('<div>') .css({ top : row * 100 + 'px', left : col * 100 + 'px' }) .text(number) .addclass('box') .appendto($('#grid'));
this function merge move 1 div another. want make animation slide grid[row1][col1] div grid[row2][col2] div.
function merge(row1, col1, row2, col2) { grid[row2][col2].remove(); grid[row2][col2] = grid[row1][col1]; grid[row1][col1] = null; var number = grid[row2][col2].text() * 2 ; grid[row2][col2] .css({ top : row2 * 100 + 'px', left : col2 * 100 + 'px' }) .text(number); return true; }
any idea please how this.
instead of css()
can try animate()
:
grid[row2][col2].text(number); grid[row2][col2].animate({ top : row2 * 100 + 'px', left : col2 * 100 + 'px' })
Comments
Post a Comment