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

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ben679
    New Member
    • Oct 2014
    • 1

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

    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

    Code:
    html
    <!DOCTYPE html> <html> <body> </form> 
    <p>Click the button:</p> 
    <button onclick="myFunction()">Try it</button> <p id="demo"></p>
    
    JS
    function myFunction() {
        var greeting;
        if (10 == 10){
            greeting = "Yes";
        } else {
            greeting = "No";
        }
        document.getElementById("demo").innerHTML = greeting;
    }
    Last edited by Rabbit; Oct 16 '14, 05:10 PM. Reason: Please use [code] and [/code] tags when posting code or formatted data.
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    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.

    Comment

    Working...