用jquery使一个按钮让div左右移动怎么弄哇。。

html-css023

用jquery使一个按钮让div左右移动怎么弄哇。。,第1张

用jquery使一个按钮让div左右移动方法如下:

就是点击“#anniu”,然后"#caozuo"div左右移动,我的代码左移了就不能移动回来了  <div class="bottom textstyle" id="caozuo"><a href="#" id="anniu"><img src="jiantou2.png" width="20" id="tanchu" /></a></div> $(document).ready(function()... 就是点击“#anniu”,然后"#caozuo"div左右移动,我的代码左移了就不能移动回来了。

<div class="bottom textstyle" id="caozuo">

<a href="#" id="anniu"><img src="jiantou2.png" width="20" id="tanchu" /></a>

</div>

$(document).ready(function() {

$("#anniu").click(function(event){

event.preventDefault()

if($('#caozuo').is({right:'0em'})){

$('#caozuo').animate({right:'-8.5em'},"fast")}

else{

$('#caozuo').animate({right:'0em'},"fast")

}

})

})

jQuery是一套跨浏览器的JavaScript库,简化HTML与JavaScript之间的操作。由John Resig在2006年1月的BarCamp NYC上发布第一个版本。目前是由 Dave Methvin 领导的开发团队进行开发。全球前10000个访问最高的网站中,有59%使用了jQuery,是目前最受欢迎的JavaScript库。

//首先需要对图片进行定位 假如图片在left:400位置

$('img').animate({left:200}).animate({top:300}).animate({left:600}).animate({top:100})