jquery element click event only allowed once? confuddled

Posted by claw on Stack Overflow See other posts from Stack Overflow or by claw
Published on 2011-03-15T00:04:18Z Indexed on 2011/03/15 0:10 UTC
Read the original article Hit count: 184

Filed under:
|
|

One a click event of an element, it only works once. Say the value is 2 it will increase/decrease/reset only once.

How to I reset the event so the user can keep clicking on the element increasing the value of the value .item-selection-amount

$('.item-selection-amount').click(function(event) {
        var amount = $(this).val();
        switch (event.which) {
            case 1:
                //set new value +
                $(this).val(amount + 1);
                break;
            case 2:
                //set new value reset
                $(this).val(0);
                break;
            case 3:
                //set new value -
                if(amount > 0){ 
                    $(this).val(amount - 1);
                }
                break;
        }
    });

Thanks

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about click