Dieser Artikel beschreibt die Implementierungsmethode von JS Simple Calculator. Teilen Sie es für Ihre Referenz. Die spezifische Implementierungsmethode lautet wie folgt:
Die Codekopie lautet wie folgt:
<html xmlns = "http://www.w3.org/1999/xhtml">
<kopf>
<title> </title>
<script type = "text/javaScript">
Funktion sum () {
// JS -Typ Conversion ParseInt (Wert, 10) bedeutet, den Wertwert in einen Dezimalwert umzuwandeln
var id1 = parseInt (document.getElementById ("Bnt1"). Wert, 10);
var id2 = parseInt (document.getElementById ("Bnt2"). Wert, 10);
var id3 = id1 + id2;
document.getElementById ("Bnt3"). value = id3;
}
</script>
</head>
<body>
<Eingabe type = "text" id = "bnt1" />+<Eingabe type = "text" id = "bnt2" /> <Eingabe type = "button" value = "=" onclick = "
</body>
</html>
Ich hoffe, dieser Artikel wird für JavaScript -Programme aller hilfreich sein.