Q:

Animate element only if position is not 0

I am trying to make ul#pikame move right it its relative position IS 0, but it keeps moving right even if position is not 0.
I know li_left is set to 0 at the beginning, and it remembers that and sticks to it, but I need li_left to update for each new click.
My code:
li_left = $('ul#pikame').css('left');
if (li_left == '0px') {
    $('a.prev').click(function (e) {
        // e.preventDefault();
        $('ul#pikame').animate({
            'left': '+=127'
        });
        e.preventDefault();
    });
}

to sum up, it should move right only ONCE, because after the first click the position left will not be 0.

A:

Your condition should be inside the click handler, not outside. 
$('a.prev').click(function (e) {
    li_left = $('ul#pikame').css('left');
    if (li_left == '0px') {
        // e.preventDefault();
        $('ul#pikame').animate({
        'left': '+=127'
    }
    e.preventDefault();
});

