我知道如何在jQuery中上下移动元素.
$("#div").animate({"left": "+=100"}, 1000); //move 100px to the right
Run Code Online (Sandbox Code Playgroud)
但我不知道是否会进行对角线运动.我正在做棋盘,我不知道如何移动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);
}
Run Code Online (Sandbox Code Playgroud)
任何的想法?非常感谢您的帮助!
Nic*_*ver 28
像这样做:
$("#div").animate({left: '+=50', top: '+=50'}, 1000);
Run Code Online (Sandbox Code Playgroud)
你想要一个动画让你到那里... for循环队列100个动画在你的情况下,你只需要一个:) 在这里看一个演示