簡単な計算機の実現機能を作り、数字1と数字2を入力して合計し、結果を出力します.
6429 ワード
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title> </title>
<style>
input{
border-radius:10px;/* */
border:1px solid #ccc;
}
</style>
</head>
<body>
<!-- oninput="value=value.replace(/[^\d]/g,'')" ( )-->
<input type="text" id="umber1" placeholder=" " oninput="value=value.replace(/[^\d]/g,'')"> +
<input type="text" id='umber2' placeholder=" " oninput="value=value.replace(/[^\d]/g,'')">
<input type="button" value="=" id="sum">
<input type='text' id="resule" placeholder=" ">
<script>
document.getElementById('sum').onclick=function(){
var umber1 = parseFloat(document.getElementById('umber1').value);//parseFloat() , 。
var umber2 = parseFloat(document.getElementById('umber2').value);
var resule = umber1 + umber2;
document.getElementById('resule').value=resule;
}
</script>
</body>
</html>