-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathjava_script.html
More file actions
26 lines (23 loc) · 869 Bytes
/
java_script.html
File metadata and controls
26 lines (23 loc) · 869 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>Java script</title>
</head>
<body>
<p>How many fingers am I holding up!</p>
<input type="text" id="number">
<button id="randomnumbers">Enter!</button>
<script type="text/javascript">
document.getElementById("randomnumbers").onclick=function(){
var numEntered = document.getElementById("number").value;
var correctNumber = Math.floor(Math.random() * 6); // returns a random integer from 0 to 9
if(numEntered==correctNumber){
alert("Congrats,You won!")
}else{
alert("Try again,The answers is"+ correctNumber);
}
}
</script>
</body>
</html>