Created
March 16, 2018 17:44
-
-
Save jouderianjr/60a86c3d488a1a35c380f0de30c5fdbb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title></title> | |
</head> | |
<body> | |
<input type="text" id="numero1" placeholder="digite o primeiro numero"> | |
<input type="text" id="numero2" placeholder="digite o segundo numero"> | |
<button id="oi">calcular</button> | |
<p id="result"></p> | |
</body> | |
<script> | |
// var button = document.getElementById('oi'); | |
// | |
// button.addEventListener('click', function () { | |
// var input1 = document.getElementById('numero1'); | |
// var input2 = document.getElementById('numero2'); | |
// var htmlResult = document.getElementById('result'); | |
// | |
// var num1 = parseInt(input1.value); | |
// var num2 = parseInt(input2.value); | |
// | |
// htmlResult.innerText = "O resultado é: " + calcular(num1,num2); | |
// }); | |
var input1 = document.getElementById('numero1'); | |
var htmlResult = document.getElementById('result'); | |
input1.addEventListener('input', function (evt) { | |
htmlResult.innerText = evt.target.value; | |
}) | |
function calcular (num1, num2){ | |
return num1 + num2; | |
} | |
</script> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment