方法一 【注】需把控件的 CSS 的 position 属性设置为 relative 或 absolute。 复制代码 代码如下: <BR>$(document).ready(function(){ <BR>$("#right1").click(function(){ <BR>$(".block1").animate({left: '+=50px'}, "slow"); <BR>}); <BR>$("#left1").click(function(){ <BR>$(".block1").animate({left: '-=50px'}, "slow"); <BR>}); <BR>}); <BR> 方法二 复制代码 代码如下: <BR>$(document).ready(function(){ <BR>$("#right2").click(function(){ <BR>$(".block2").css("margin-left","+=50px"); <BR>}); <BR>$("#left2").click(function(){ <BR>$(".block2").css("margin-left","-=50px"); <BR>}); <BR>}); <BR> 方法三 复制代码 代码如下: <BR>$(document).ready(function(){ <BR>$("#right3").click(function(){ <BR>$(".block3").animate({width:"+=50px"}, 222); <BR>}); <BR>$("#left3").click(function(){ <BR>$(".block3").animate({width:"-=50px"}, 222); <BR>}); <BR>}); <BR> 全部代码 复制代码 代码如下: 无标题文档 <br><br>$(document).ready(function(){ <BR>$("#right1").click(function(){ <BR>$(".block1").animate({left: '+=50px'}, "slow"); <BR>}); <BR>$("#left1").click(function(){ <BR>$(".block1").animate({left: '-=50px'}, "slow"); <BR>}); <br><br>$("#right2").click(function(){ <BR>$(".block2").css("margin-left","+=50px"); <BR>}); <BR>$("#left2").click(function(){ <BR>$(".block2").css("margin-left","-=50px"); <BR>}); <br><br>$("#right3").click(function(){ <BR>$(".block3").animate({width:"+=50px"}, 222); <BR>}); <BR>$("#left3").click(function(){ <BR>$(".block3").animate({width:"-=50px"}, 222); <BR>}); <BR>}); <BR> « » « » « » 效果图