By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,009 Members | 1,487 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,009 IT Pros & Developers. It's quick & easy.

Making a reset button that reset a javascript if/else statement answer

P: 1
I made an If/Else statement that would tell if 10 equaled 5 and it would give the answer. I was wondering if i could make a reset to reset the answer given.

heres my code

Expand|Select|Wrap|Line Numbers
  1. html
  2. <!DOCTYPE html> <html> <body> </form> 
  3. <p>Click the button:</p> 
  4. <button onclick="myFunction()">Try it</button> <p id="demo"></p>
  5.  
  6. JS
  7. function myFunction() {
  8.     var greeting;
  9.     if (10 == 10){
  10.         greeting = "Yes";
  11.     } else {
  12.         greeting = "No";
  13.     }
  14.     document.getElementById("demo").innerHTML = greeting;
  15. }
Oct 16 '14 #1
Share this Question
Share on Google+
1 Reply


Rabbit
Expert Mod 10K+
P: 12,364
Please use code tags when posting code or formatted data.

Yes, you can do that. You do it the same way you did for the Try it button. Except you just leave out the if stuff.
Oct 16 '14 #2

Post your reply

Sign in to post your reply or Sign up for a free account.