开发者

How to move a div to a predefined path using the keyboard, AJAX & jQuery

Hello is there any way to use the keyboard lets say the Enter button and move a div to a path that I defined earlier ? With path I mean for example to move some steps right, then down, then left and so on. The main goal is to use a path either amanual with keypress or with a body o开发者_Python百科nload command. Any help/idea/example is appeciated..


You can use jQuery's animate() on the div in response to keypress events.

$(document).keypress(function(e) {
    var anim_params;
    if (div in state 1) {
        anim_params = state 2 params;
    } else  if (div in state 2) {
        anim_params = state 3 params;
    } else if (...) {
        ...
    }

    $('#div_id').animate(anim_params);
});

Of course you can replace those if statements with a lookup, but you get the idea.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜