Reputation: 22480
The animate functions does thre times exactly the same thing.
So how can I do this while writing .animate(..
only once?
There should be an easy way but I couldn't figure out.
This is what I've got: see fiddle
$('.button').on('click',function(){
$('header').animate({
'left': '315px'
}, 500, function() {
});
$('main').animate({
'left': '315px'
}, 500, function() {
});
$('footer').animate({
'left': '315px'
}, 500, function() {
});
});
Upvotes: 2
Views: 32
Reputation: 82241
By using comma separated multiple selectors. This way:
$('header,main,footer').animate({
'left': '315px'
}, 500, function() {
});
Upvotes: 3