Reputation: 717
I want the ul
to move to the left by 200 each time, but it only happens once. Why?
$('a.next').click(function(e) {
// e.preventDefault();
$('ul#pikame').animate({
'left': -200
});
e.preventDefault();
});
Upvotes: 4
Views: 2860
Reputation: 5008
You should try:
'left': '-=200'
You're only setting the value statically.
Basically you're saying "set left value to -200". What you want to say is: "decrease left value by 200"
Upvotes: 8
Reputation: 4211
It's because -200 implies move to -200px not -200 more pixels try this.
$('a.next').click(function(e) {
// e.preventDefault();
$('ul#pikame').animate({
'left': $('ul#pikame').position().left-200
});
e.preventDefault();
});
Upvotes: 1