Jquery Plus/Minus Incrementer

后端 未结 10 1148
挽巷
挽巷 2021-01-01 03:53

I want to have a client side Plus / Minus system where a user can click the plus and a value is incremented by 1, minus and the value is decreased by 1, the value should nev

10条回答
  •  醉梦人生
    2021-01-01 04:11

    this is easy and dynamic way to incrment and decrement value

    this is the html part

      

    this is the jquery part.

        function increment(obj)
        {
        var count = parseInt($(obj).parent().parent().find('input').val());
        $(obj).parent().parent().find('input').val(count+1);
       }
    
       function decrement(obj)
       {
        var count = parseInt($(obj).parent().parent().find('input').val());
        if(count != 0)
        {
           $(obj).parent().parent().find('input').val(count - 1);  
        }
    
    }
    

提交回复
热议问题