Variables not updating?

Variables not updating?

From what I have read, my variables should be dumping their data and getting new data when I call the function again. I cannot figure out why my code isn't doing this though.

When the page first loads everything seems to be working. The function runs, and it grabs the price/qty. When I click .switcher-label, or any of the other elements listed below it doesn't change the variables though. They just stay the exact same as they were when the page first loaded. I have no idea what is going on here, I went as far as running an if statement to check if the price is above 0 and setting everything to null if it was, but it still didn't change anything.


Thanks in advance for your help.

  1. <script type="text/javascript">

  2.     var bessie = function(){

  3.         //Pull html code for plus/minus qty selector
  4.         var qtyCode = jQuery('.qtyswitcher-qty').html();

  5.         //Get value of qty that is currently selected
  6.         var qty = jQuery('#qtyswitcher-qty').val(); 

  7.         //Pull the current price and change the string to a number
  8.         var price = jQuery('.price').first().text().replace(/[^0-9\.]+/g,""); 

  9.         //multiply price by qty to get the total for the users current selection
  10.         var total = price * qty;

  11.         //New html that will be inserted into the page
  12.         var newContent = '<p class="multiply">' + '$' + price + '/ea</p>' + '<p class="multiply2">x</p>' + '<div id="qty">' + qtyCode + '</div>' + '<p class="multiply3">=</p> <p class="multiply">' + '$' + total.toFixed(2) + '</p>';

  13.         //New html being inserted
  14.         jQuery(".qtyswitcher-qty").replaceWith(newContent);
  15.     }; 


  16.     bessie();
  17.     jQuery('.switcher-label').click(bessie());
  18.     jQuery('#qtyswitcher-oneless').click(bessie());
  19.     jQuery('#qtyswitcher-onemore').click(bessie());

  20.     </script>