. . :
$(function(){
$("#one").click(function(){
$("div").animate({top: '250px'});
});
$("#sec").click(function(){
$("div").animate({top: '0px'});
});
$("#thi").click(function(){
$("div").animate({left: '250px'});
});
$("#for").click(function(){
$("div").animate({left: '0px'});
});
});
CSS:
.box{
background-color:grey;
height:20px;
width:20px;
position:absolute;
top: 0px;
left: 0px;
}
Note that you only need to change the left and top attributes using jQuery. This is working correctly. You can change the starting position of a field using css, and then move it accordingly in jQuery.
source
share