如何在jQuery中移动Diagonal Movement中的元素?

我知道如何在jQuery中上下移动元素。

$("#div").animate({"left": "+=100"}, 1000); //move 100px to the right 

但我不知道是否会进行对角线运动。 我正在做棋盘,我不知道如何移动Bishop效果。 请查看以下URL http://chess.diem-project.org/

我确实喜欢这个…但这不是一个正确的方法。

 for(var i = 0;i<50;i++){ // move down and move right 1 pixel at a time to get effect $("#div").animate({"left": "+="+x}, 1); $("#div").animate({"top": "+="+x}, 1); } 

任何的想法? 真的很感激你的帮助!

像这样做:

  $("#div").animate({left: '+=50', top: '+=50'}, 1000); 

你想要一个动画让你到那里… for循环在你的情况下排队100个动画,你只需要一个:) 在这里看一个演示