JavaScript If Statements
JavaScript If Statements
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() {
if (document.getElementById("weather").value=="rain") {
alert ("it's raining");
} else {
alert("it's not raining!");
}
}
</script>
</body>
</html>