javascript - JQuery animating more elements -
i'm trying set application , need animate several items @ 1 time.
function getdata() { for(i=0, i<data.length, i++) { ... animate(id, top, left); } } function animate (id, top, left) { $("#" + id).animate({top: top, left: left}, {duration: 1000, queue: false}); }
what is, gets data server through ajax, gets id, top , left position. have divs these ids , need animate them position given in left , top coordinates. problem is, when call function elements jump given position except last one, animates should. issue?
you can use jquery multiselection:
$("#element0, #element1").fadein()
in case:
function getdata() { var ids = "" for(i = 0; < data.length; i++) { // retrieve 'id', top , left ids += "#" + id if (i < data.length - 1) { ids += "," } } animate(ids, top, left); } function animate (ids, top, left) { $(ids).animate({top: top, left: left}, {duration: 1000, queue: false}); }
this animate element, selected 'id', simultaneously.
Comments
Post a Comment