Created
November 14, 2016 16:24
-
-
Save alexandreaquiles/b0792460ac99d48946b7e584b7b1960c to your computer and use it in GitHub Desktop.
Cálculo IMC com jQuery
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> | |
<body> | |
<label>Peso <input id="peso"/> kg</label><br/> | |
<label>Altura <input id="altura"/> m</label><br/> | |
<button id="botao">Calcular IMC</button> | |
<div id="resultado"> | |
</div> | |
<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script> | |
<script> | |
$('#botao').click(function () { | |
var peso = $('#peso').val(); | |
var altura = $('#altura').val(); | |
var imc = peso / (altura * altura); | |
var hr = $('<hr>'); | |
var spanIMC = $('<span>').text('IMC: ' + imc); | |
$('#resultado').append(hr).append(spanIMC); | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment