My conversion button code just wont work on a second click

Please I really need help with my conversion button! I have tried different functions just wont work
Someone please have a look at code and tell me whats wrong and i will really appreciate it

it only toggle once and the code I have there now is not the best but its something that works once
Someone please come up with something for me!

Hi @prizemac

The button is only doing one thing at the moment and that is to put the Fahrenheit value into the h2. You need to make it so that it can detect whether it’s currently displaying Celsius or Fahrenheit and then change to the other value, you could use a class to identify the current unit.

Perhaps something like this if you get stuck:

/*toggle button*/
$("button").click(function() {
  if ($("#tempC").hasClass("celsius")) {
    $("#tempF").html(tempFah + "°f");
  } else {
    $("#tempF").html(tempCel + "°c");
1 Like

Not all heroes wear cape, joesmith100 . Thanks so much I love you, I honestly do :blush:
It worked!