title: Overriding a variable retrieved from val()
body: <p>In the following code, how would I go about overriding the "donateAmount" variable whenever someone initiates the click function? </p>
  
  <p>In other words, whenever someone clicks it removes whatever is inside the variable "donateAmount" and replaces with the new val() amount.</p>
  
  <p>Thank you</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>This code below now works, thanks to fixing the variable scope issue.</p>
  
  <pre><code>$('label input').click(function () {
      if ($('label input').is(':checked')) {
          $(this).parent().addClass('checked');
          $('.donate-now label').not($(this).parent()).removeClass('checked');
          var donateAmount = $(".checked input").val();
  
  
       }
  
  
      $('#click').click(function(){
  
          if ($('label #other').is(':checked')) {
              donateAmount = $("#otherAmount").val();
          }
             $('p').html(donateAmount);
  
      });   
   });
  </code></pre>