开发者

moving elements with jquery

How can I use jQuery to move an element from:

position: absolute;
left: 169px;
top: 182px;

to:

position: absolute;
left: 169px;
top: 230px;

with clear moving so not just css, it has开发者_运维知识库 to be moving.

Thanks.


http://api.jquery.com/animate/

Demo: http://jsfiddle.net/pHwMK/

JS:

$(function() {
  $("div.ele").animate({ top: '230px' });
});


What you mean is animation? Assuming an element with id="someElement" already has position:absolute and left:169px, then:

$('#someElement').animate({top: 230});

If you need to set the initial CSS on the element before animating it, then have an extra .css() call before .animate():

$('#someElement').css({
    position: 'absolute',
    left: 169,
    top: 182
}).animate({top: 230});
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜