0% found this document useful (0 votes)
36 views

JavaScript If Statements

The document is an HTML page with JavaScript code to check the weather using an if statement. It contains an input field and button. When the button is clicked, it checks the value entered in the input field. If the value is "rain", it alerts "it's raining". If the value is anything else, it alerts "it's not raining!". The if statement allows different code to run depending on the condition.

Uploaded by

Ania Neal
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views

JavaScript If Statements

The document is an HTML page with JavaScript code to check the weather using an if statement. It contains an input field and button. When the button is clicked, it checks the value entered in the input field. If the value is "rain", it alerts "it's raining". If the value is anything else, it alerts "it's not raining!". The if statement allows different code to run depending on the condition.

Uploaded by

Ania Neal
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 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() {


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

alert ("it's raining");

} else {

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

}

}

</script>

</body>
</html>

You might also like