Last active
August 21, 2018 14:07
-
-
Save erySanDriver/95b1381f501d86d28d00bcf38249ed57 to your computer and use it in GitHub Desktop.
This file contains 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
<script> | |
($function () { | |
var $test; // 各テキストボックスに入る数値を順番に格納する配列 | |
var $result; // 計算結果を格納する変数 | |
// 同じクラス名の値をeachで取得する | |
$('.test').each(function (i) { | |
// 1.テキストボックスへの入力をトリガーにする | |
$(this).keyup(function () { | |
// それぞれのテキストボックスに入った値を取得 | |
$test[i] = ParseInt($(this).val()); | |
}); | |
// 配列に格納したそれぞれのテキストボックスの値で計算 | |
for (var $val of $test) { | |
$result += $val; | |
} | |
$('.caluculate').text($result); | |
}); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment