Confused about how to access eda at this point $("#test").text("="+eda);

  var eda=""; $(document).on('tap', '#linkbreakfast', function() { eda="breakfast";}); $(document).on('tap', '#linkdinner', function() { eda="dinner";}); $("#test").text("="+eda); 
  • one
    let me guess, by clicking the text in $("#test") should have been updated, but it is not updated? :) - Grundy
  • in your event, the assignment of a value to a variable will work, but text("="+eda); has already been completed by this time - Invision

1 answer 1

 var eda=""; $(document).on('tap', '#linkbreakfast', function() { SetEda("breakfast");}); $(document).on('tap', '#linkdinner', function() { SetEda("dinner");}); function SetEda(value) { eda = value; $("#test").text("="+eda); } 
  • what's the point then eda variable? - Invision
  • one
    @Invision, in that it can be used somewhere further in the code - Grundy
  • fortune telling on the coffee grounds - Invision
  • And how then to get in another place? var eda=SetEda(); ? - zkolya
  • @zkolya - Get what? Where eda is visible, you can simply use it. - Igor