Reputation: 121
I've been all over the place looking for this. There are some answers out there but none of them work.
All I want to do is slowly move a div to the left when a user does a mouseover on a button.
This works to make the div move:
$("#myDiv").offset({left:-1000});
but all my attempts to animate the move cause the move itself to fail.
Upvotes: 2
Views: 15258
Reputation: 78971
Use .animate() function like this
$("#myDiv").animate({ left: '-1000' });
Update:
Since your division is floated to the left, you can animate the property using marginLeft
instead.
$("#myDiv").animate({ marginLeft: '-1000' });
Upvotes: 3
Reputation: 350
Use the animate function of jQuery to do so.
$('button').mouseover(function () {
$('#mydiv').animate({left: '100px'}, 'slow');
});
Upvotes: 1