我的Jquery图像赢得了';别动

我的Jquery图像赢得了';别动,jquery,html,Jquery,Html,嗨,我正在制作jquery动画。我对jquery没有太多经验,但我知道基本语法。 这是我到目前为止得到的 <!DOCTYPE html> <html> <title>Nathan</title> <head> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"/> <script> $(document).

嗨,我正在制作jquery动画。我对jquery没有太多经验,但我知道基本语法。 这是我到目前为止得到的

 <!DOCTYPE html>
<html>
<title>Nathan</title>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"/>
<script>
$(document).ready(function(){ 
$("button").click(function(){
  $("#N").animate({left:'250px'});
  });
});
</script> 
</head>

<body>
<button>CLICK</button>
<div id="N" style="margin-left:200px;"><image src="http://upload.wikimedia.org/wikipedia/en/8/88/Letter_N-1-.png" height="44" width="44"/></div>
 <image src="http://b68389.medialib.glogster.com/media/3cf5bc6910ded698d225a3be66fb7bec27443f45eaa12ee7d207847f79152a10/bubble-graffiti-alphabet-letter-l.jpg" height="44" width="44"/>
</body>
</html>

内森
$(文档).ready(函数(){
$(“按钮”)。单击(函数(){
$(“#N”).animate({左:'250px'});
});
});
点击
我尝试使用此函数:

<div id="N" style="margin-left:200px;"><image src="http://upload.wikimedia.org/wikipedia/en/8/88/Letter_N-1-.png" height="44" width="44"/></div>

使用我的jquery脚本

但是,当我单击按钮时,图像不会移动

我做错了什么


我如何编辑代码,使其与我的
一起工作?给id为“N”的div提供
位置:相对的


检查这个

将以下代码直接复制到页面中,它应该可以工作:

<!DOCTYPE html>
<html>
<head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <script type='text/javascript' src='//code.jquery.com/jquery-1.10.1.js'></script>

<script type='text/javascript'>//<![CDATA[ 
$(window).load(function(){
$(document).ready(function(){ 
$("button").click(function(){
    $("#N").animate({'left':'250px'});
  });
});
});//]]>  

</script>
</head>
<body>
  <button>CLICK</button>
<div id="N" style="position:relative;margin-left:200px;"><image src="http://upload.wikimedia.org/wikipedia/en/8/88/Letter_N-1-.png" height="44" width="44"/></div>
 <image src="http://b68389.medialib.glogster.com/media/3cf5bc6910ded698d225a3be66fb7bec27443f45eaa12ee7d207847f79152a10/bubble-graffiti-alphabet-letter-l.jpg" height="44" width="44"/>

</body>
</html>

//  
点击

通过CSS设置位置:

#N {
    position:relative;
}

呵呵。。。解决这个问题的办法是加一个加号

      $("#N").animate({margin-left:'+250px'});
试试这个


position:relative

这不起作用,因为
div\N
元素处于静态位置。正如其他地方提到的,他需要在元素中添加
position:relative
。出于某种原因,小提琴可以工作,但当我添加左边距或相对于实际脚本的位置时,它就不起作用了。我已经尝试了所有方法。你认为它可能是我设置
元素或
元素的地方吗。因为js fiddle会为您自动将其放入输出中。既然小提琴能演奏,但我的剧本却不行,那是不是@Zwordok我会在2分钟内发布完整的代码。试试看,我觉得很愚蠢。我忘了

      $("#N").animate({margin-left:'+250px'});