title: how to check if button is clicked?
body: <p>i make a button i want to add check if button is clicked then some code work here is my code:
  i make a button i want to add check if button is clicked then some code work here is my code:
      </p>
  
  <pre><code>$("body").on('change', '.quantity', function() {
          var that = $(this);
          if ($('#btnAdd').is(':clicked')){
              $('#itemscounter').val("1");
              var counter=$('#itemscounter').val();
              var quantity=$('#quantity').val();
              var unitprice=$('#unitprice').val();
              var linetotal=quantity*unitprice;
              that.parent().find('.linetotal').val(linetotal) 
              $("#invoicetotalamount").val(+linetotal)
              var discount=document.getElementById('discount').value ;
              var discountamount= discount/100 * linetotal;
              var amount=linetotal-discountamount;
              $("#balanceamount").val(+amount);
          }
          else{           
          var counter=$('#itemscounter').val();
          var quantity=$('#quantity').val();
          var unitprice=$('#unitprice').val();
          var linetotal=quantity*unitprice;
          $('#linetotal').val(+linetotal);
           var sum=linetotal;
          for (i = 2; i &lt;=counter; i++) {
              var quantity=$('#quantity' + i).val();
              var unitprice=$('#unitprice' + i).val();
              var linetotal=quantity*unitprice;
              $('#linetotal' + i).val(+linetotal);            
              sum=+sum +(+(linetotal));           
              }
          $("#invoicetotalamount").val(+sum); 
          var discount=document.getElementById('discount').value ;
          var discountamount= discount/100 * sum;
          var amount=sum-discountamount;
          $("#balanceamount").val(+amount);
          }
  
      });
  </code></pre>
  
  <p>but when i click it not work,how i do this?</p>