我正在尝试使用 jQuery 做一个快速货币计算器,但出了点问题,它得到的值是“NaN”。
我已经尝试以几种方式理解它,但不幸的是没有任何帮助,我在下面向您发送了我的代码。
$(document).ready(function() {
var total = 0;
$("#amountin,#amountouy").on("change", function() {
var amountinval = $("#amountin").val();
var amountoutval = $("#amountout").val();
function2(amountinval, amountoutval);
});
function function2(val1, val2) {
$('#amountValue').on('keyup', function() {
var total = 0;
$('#amountValue').each(function(i, v) {
var amountValue = $(v).val().length > 0 ? $(v).val() : 0;
console.log(amountValue, val1, val2)
total = parseInt(amountValue * val1 * val2);
});
$('#totalvalue').text(total);
});
}
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="form-row align-items-center">
<div class="col-lg-3">
<label for="inlineFormInput" class="converter-label-form">Kwota</label>
<input type="number" class="form-control converter-input-form" id="amountValue" name="amountValue" aria-describedby="numberHelp" placeholder="100">
</div>
<div class="col-lg-9">
<label class="converter-label-form" for="amountin">Przelicz z:</label>
<select class="custom-select converter-input-form input" id="amountin" name="amountin">
<option>Wybierz</option>
<option value="0,1528" data-value="0,1528" data-symbol="EUR">Euro</option>
<option value="1" data-value="1" data-symbol="PLN">Polski złoty</option>
</select>
</div>
</div>
<div class="form-row align-items-end">
<div class="col-lg-8">
<label class="converter-label-form" for="amountout">Przelicz na:</label>
<select class="custom-select converter-input-form" id="amountout" name="amountout">
<option>Wybierz</option>
<option value="0,1528" data-value="0,1528" data-symbol="EUR">Euro</option>
<option value="1" data-value="1" data-symbol="PLN">Polski złoty</option>
</select>
</div>
<div class="col-lg-4">
<div id="totalvalue" name="totalvalue"></div>
</div>
</div>
aluckdog
肥皂起泡泡
相关分类