javascript if statements

2
If Statements: if.html <!doctype html> <html> <head> <title>Learning Javascript</title> <meta charset="utf-8" /> <meta http-equiv="Content-type" content="text/html; charset=utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1" /> </head> <body> <p>What is the weather?</p> <input id="weather" /> <button id="myButton">Submit</button> <script type="text/javascript"> document.getElementById("myButton").onclick=function() {

Upload: ania-neal

Post on 06-Nov-2015

219 views

Category:

Documents


0 download

DESCRIPTION

if statements for js

TRANSCRIPT

  • If Statements: if.html !!

    Learning Javascript

    What is the weather?

    Submit

    document.getElementById("myButton").onclick=function() {

  • if (document.getElementById("weather").value=="rain") {

    alert ("it's raining");

    } else {

    alert("it's not raining!");

    }

    }