当我按下键盘上的某个键时,我尝试使用 JQuery 移动图像,但它不起作用。谁能告诉我这是什么问题吗?
代码如下:
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script>
$(document).ready(function(){
$(document).keydown(function(){
$(document).find("img").animate({
top:"+=100px",
});
});
});
</script>
</head>
<body>
<img src="player.jpg">
</body>
</html>
非常感谢!
最佳答案
这是您唯一应该更改的内容:
<img style="position: relative" src="player.jpg">
关于jquery - 为什么我无法通过 JQuery 移动图像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22895146/