eric2872
eric2872

Reputation: 122

jQuery If Then else Statement

how would I would I write

If (margin-top for #ted = 100px)
then
(.animate #ted margin- top: 20px)
else
(.animate #ted margin- top: 50px)

Can this be done and if so can you show me how? Thank You for all the help!

Upvotes: 0

Views: 2325

Answers (1)

volter9
volter9

Reputation: 735

It would be something like this:

var ted = $('#ted');

if (ted.css('margin-top') === '100px') {
    ted.animate({'margin-top' : '20px'});
}
else {
    ted.animate({'margin-top' : '50px'});
}

Good luck!

Upvotes: 2

Related Questions