title: jquery plus/minus selector
body: <p>I have a plus/minus jquery selector on my page. When the page loads or whenever the number gets to 1 I would like the minus button to be greyed out to simulate inactive. Here is my code and a fiddle <a href="https://jsfiddle.net/pgxvhs83/2/" rel="nofollow">https://jsfiddle.net/pgxvhs83/2/</a></p>
  
  <pre><code>&lt;span class="form-title"&gt;Quantity:&lt;/span&gt;
  &lt;form id='myform' method='POST' action='#' class="numbo"&gt;
  &lt;input type='button' value='–' class='qtyminus' field='quantity' style="font-weight: bold;" /&gt;
  &lt;input type='text' name='quantity' value='1' class='qty' style="margin-bottom: 0px !important"/&gt;
  &lt;input type='button' value='+' class='qtyplus' field='quantity' style="font-weight: bold;" /&gt;
  &lt;/form&gt;
  
  jQuery(document).ready(function(){
  // This button will increment the value
  $('.qtyplus').click(function(e){
      // Stop acting like a button
      e.preventDefault();
      // Get the field name
      fieldName = $(this).attr('field');
      // Get its current value
      var currentVal = parseInt($('input[name='+fieldName+']').val());
      // If is not undefined
      if (!isNaN(currentVal)) {
          // Increment
          $('input[name='+fieldName+']').val(currentVal + 1);
      } else {
          // Otherwise put a 0 there
          $('input[name='+fieldName+']').val(1);
      }
  });
  // This button will decrement the value till 0
  $(".qtyminus").click(function(e) {
      // Stop acting like a button
      e.preventDefault();
      // Get the field name
      fieldName = $(this).attr('field');
      // Get its current value
      var currentVal = parseInt($('input[name='+fieldName+']').val());
      // If it isn't undefined or its greater than 0
      if (!isNaN(currentVal) &amp;&amp; currentVal &gt; 1) {
          // Decrement one
          $('input[name='+fieldName+']').val(currentVal - 1);
      } else {
          // Otherwise put a 0 there
          $('input[name='+fieldName+']').val(1);
      }
  });
  });
  </code></pre>