title: Jquery toggle input value and button class
body: <p>I have a PHP page that loads a form with pre-populated values from a MySQL database. Users are able to edit the form and update it with their desired data, this works.</p>
  
  <p>I would like to offer them the ability to toggle <strong>one</strong> of the fields if it's <em>not applicable</em>. By doing so, the field will be populated with the text 'N/A' and the button class should change to 'btn-warning'. When clicked again the 'N/A' should be removed and the previous data re-inserted - is this possible?</p>
  
  <p>So far I have it sort of working... when the button is clicked the input is populated with 'N/A' and the class changes, however it doesn't toggle, i.e the previous data doesn't re-appear and the 'N/A' remains.</p>
  
  <p>I have created a <a href="https://jsfiddle.net/6pqugkg3/2/" rel="nofollow">FIDDLE</a>, any help is appreciated.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>$(document).ready(function() {
    $("#ipclear").click(function() {
      $("#ip").val('N/A');
      $(this).toggleClass('btn-default').toggleClass('btn-warning');
    });
  });</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"&gt;&lt;/script&gt;
  &lt;script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.6/js/bootstrap.js"&gt;&lt;/script&gt;
  &lt;link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.6/css/bootstrap.css" rel="stylesheet" /&gt;
  
  &lt;div class="input-group"&gt;
    &lt;input type="text" name='ip' id="ip" class='form-control' value="1.2.3.4"&gt;
    &lt;div class="input-group-btn"&gt;
      &lt;button type="button" class="btn btn-default" id="ipclear"&gt;Not Applicable&lt;/button&gt;
    &lt;/div&gt;
  &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>