0

okay i have a mystery here that i can't seem to find the solution for. And can't seem to find any documentation backing it up or giving me a solution.

but i have a lot of divs with some infomation stored in the data attribute. like so:

<div data-name="valA"></div>
<div data-name="valB></div>

and im getting the stored infomation with this function

function finishFood(that) {

  var food_ammount = parseFloat(jQuery('.foodinfo-form #food_ammount').val().replace(",", "."));
  console.log(food_ammount);

  var food_name = jQuery('.foodinfo-form .food_name').data('name');

  console.log(food_name);

}

and it works great the first time. But next time the function is called it returns the old the value?

i have even tried defining the variables first as empty and tried null the variables after use nothing is working. Every time i call the function the first value is returned. the food_ammount is working and is returning the correct updated value.

bymem
  • 79
  • 1
  • 8
  • what do you mean "returns the old value" - you're never updating the value. Please provide a [mcve] to demonstrate your problem – Jamiec Jul 17 '17 at 16:19
  • no im not updating the value there in that function, does that in another. And i can see it being updated in the html. – bymem Jul 17 '17 at 16:20

0 Answers0