Untitled
unknown
plain_text
6 months ago
1.1 kB
1
Indexable
Never
<!DOCTYPE HTML> <html> <head> <script> let ip1 = document.querySelector("#ip1"); let ip2 = document.querySelector("#ip2"); let add = document.querySelector("#Addition"); let sub = document.querySelector("#Subtraction"); let mul = document.querySelector("#Multiplication"); let div = document.querySelector("#Division"); let ans = document.querySelector("#answer"); let clr = document.querySelector("#clear"); // ans.onkeydown = function(e){ // e.preventDefault(); // } let a = Number(ip1.value); let b = Number(ip2.value); add.addEventListener("click", function(){ console.log("OK"); ans.value=Number(ip1.value)+Number(ip2.value); }) sub.addEventListener("click", function(){ console.log("OK"); ans.value=Number(ip1.value)-Number(ip2.value); }) mul.addEventListener("click", function(){ console.log("OK"); ans.value=Number(ip1.value)*Number(ip2.value); }) div.addEventListener("click", function(){ console.log("OK"); ans.value=Number(ip1.value)/Number(ip2.value); }) </script> </head> </html>