この記事では、JS Simple Calculatorの実装方法について説明します。参照のためにそれを共有してください。特定の実装方法は次のとおりです。
コードコピーは次のとおりです。
<html xmlns = "http://www.w3.org/1999/xhtml">
<head>
<title> </title>
<script type = "text/javascript">
function sum(){
// jsタイプ変換parseint(値、10)は、値の値を小数値に変換することを意味します
var id1 = parseint(document.getElementById( "bnt1")。値、10);
var id2 = parseint(document.getElementById( "bnt2")。値、10);
var id3 = id1 + id2;
document.getElementById( "bnt3")。value = id3;
}
</script>
</head>
<body>
<入力型= "text" id = "bnt1" />+<input type = "text" id "bnt2" /> <input type = "button" value = "=" onclick = "sum()" /> <input type = "text" readonly = "readonly" = "bnt3" />>
</body>
</html>
この記事がみんなのJavaScriptプログラミングに役立つことを願っています。