-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample4.js
More file actions
27 lines (21 loc) · 865 Bytes
/
Copy pathexample4.js
File metadata and controls
27 lines (21 loc) · 865 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
var addition = document.getElementById("add"),
subtraction = document.getElementById("subtract"),
one = document.getElementById("one"),
two = document.getElementById("two");
addition.addEventListener("click",add,false);
function add(){
var result = parseInt(one.value) + parseInt(two.value);
document.getElementById("result").value = result;
document.getElementById("para").innerHTML = "You performed addition.";
}
subtraction.addEventListener("click",subtract,false);
function subtract(){
var result = parseInt(one.value) - parseInt(two.value);
document.getElementById("result").value = result;
document.getElementById("para").innerHTML = "You performed subtraction.";
}
one.addEventListener("blur",display,false);
two.addEventListener("blur",display,false);
function display(){
document.getElementById("para").innerHTML ="Input field blurred";
}