How to increase the value of a quantity field with jQuery?
        Posted  
        
            by amir
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by amir
        
        
        
        Published on 2009-07-31T08:45:27Z
        Indexed on 
            2010/04/03
            21:13 UTC
        
        
        Read the original article
        Hit count: 188
        
jQuery
I have a form with some quantity field and a plus and minus sign on each side,
    <form id="myform">
        product1
        <input type="submit" value="+" id="add">
        <input type="text" id="qty1">
        <input type="submit value="-" id="minus">
        product2
        <input type="submit" value="+" id="add">
        <input type="text" id="qty2">
        <input type="submit value="-" id="minus">
    </form>
I'd like to increase the value of the field by one if the add button is pressed and decrease by one if minus is pressed. Also the value shouldn't get less than 0.
Is there a way to do this in jQuery?
© Stack Overflow or respective owner