title: Save previous value in jQuery toggle method
body: <p>I have a form where the user is able to select the type of job Ad and the locations that he wishes to advertise. The job Ad price changes depending the type of the job offer and the number of locations.</p>
  
  <p>Everything is working, but there is one thing missing or not working, for example there is a checkbox with a <code>FULLPACK</code> value, where basically if the user selects it it receives a new price (discount), but when I toggles out case the user doesnt choose this option I need the price updates to the previous price number, but can´t figure out the best way.</p>
  
  <p>My code:</p>
  
  <pre><code>var adType;
  var totalprice = 0.0;
  var location;
  var countLocations =1;
  
  //hide step 2 div
  $('#step2').hide();
  $('#totalprice').html(totalprice);
  $('.adType').change(function () {
      //after select one show next step
      $('#step2').show('slow');
      adType = $(this).val();
      //var checked = $("#isAgeSelected").is(':checked').val();   
      console.log(adType);
      switch(adType) {
          case "platinum":
              totalprice = 250.00;
              $('#totalprice').html(totalprice*countLocations)
              break;
          case "gold":
               totalprice = 125.00;
               $('#totalprice').html(totalprice*countLocations)
              break;
          case "silver":
               totalprice = 50.00;
               $('#totalprice').html(totalprice*countLocations)
              break;        
          default:
              totalprice = 0.00;
              $('#totalprice').html(totalprice*countLocations)
      }
  });
  
  $('.location').change(function () {
      location = $(this).val();
      countLocations = $('[name="countrylocation[]"]:checked').length;
      $('#totalprice').html(totalprice*countLocations);
      console.log(countLocations);
      if (location == 'FULLPACK') {
          $( "#allPackage" ).toggle(function() {
               $('#totalprice').html("new Price!")
          });     
      }
  });
  </code></pre>
  
  <p>HTML:</p>
  
  <pre><code>&lt;input class="adType" name="adType" type="radio" value="platinum"&gt;
  &lt;input class="adType" name="adType" type="radio" value="gold"&gt;
  &lt;input class="adType" name="adType" type="radio" value="silver"&gt; 
  
  &lt;div class="col-md-12" id="step2"&gt;
      &lt;h3&gt;Step 2&lt;/h3&gt;
      &lt;div id="allPackage"&gt;
          &lt;label class="checkbox"&gt;&lt;input checked class="location" name=
          "countrylocation[]" type="checkbox" value="UK"&gt; UK
          (default)&lt;/label&gt; &lt;label class="checkbox"&gt;&lt;input class="location"
          name="countrylocation[]" type="checkbox" value="SP"&gt; Spain&lt;/label&gt;
          &lt;label class="checkbox"&gt;&lt;input class="location" name=
          "countrylocation[]" type="checkbox" value="IT"&gt; Italy&lt;/label&gt;
      &lt;/div&gt;&lt;label class="checkbox"&gt;&lt;input class="location" name=
      "countrylocation[]" type="checkbox" value="FULLPACK"&gt; Full Language
      Package&lt;/label&gt;
  &lt;/div&gt;
  &lt;div class="col-md-9"&gt;
      &lt;p&gt;Price: &lt;span id="totalprice"&gt;&lt;/span&gt; EUR&lt;/p&gt;
  &lt;/div&gt;
  </code></pre>