-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathswap.html
More file actions
38 lines (25 loc) · 669 Bytes
/
swap.html
File metadata and controls
38 lines (25 loc) · 669 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
27
28
29
30
31
32
33
34
35
36
37
38
<!DOCTYPE html>
<html>
<head>
<title>Swapping two Numbers</title>
</head>
<body>
Enter Your First Number: <input id="first"> <br><br>
Enter Your Second Number: <input id="second"><br><br>
<button onClick="swap()">Swap</button><br><br>
After Swapping First Number: <input id="answer1"><br><br>
After Swapping Second Number: <input id="answer2">
<script type="text/javascript">
function swap(){
var a,b,t;
a=Number(document.getElementById('first').value);
b=Number(document.getElementById('second').value);
t=a;
a=b;
b=t;
document.getElementById('answer1').value=a;
document.getElementById('answer2').value=b;
}
</script>
</body>
</html>