gpt4 book ai didi

javascript - .change jQuery 不改变数据

转载 作者:行者123 更新时间:2023-12-02 21:03:07 25 4
gpt4 key购买 nike

我在使用 jQuery .change 时遇到一个小问题,当我点击数据时,数据没有改变。

我正在使用 ddSlick。

我想要达到的效果是这样的:http://www.convertmymoney.com/ -因此,当输入金额时,数据已经另外发生变化,当有人输入金额并更改货币(标志)时,它也会更改数据,不幸的是,对我来说情况并非如此。

$(document).ready(function() {
var total = 0;

$("#amountin, #amountout,#amountValue").on("change", function() {
cal();
});

$("#amountValue").on("keydown", function() {
cal();
});


$("#exchange").on("click", function() {
var amountinval = $("#amountin").val();
var amountoutval = $("#amountout").val();


cal();
});

function cal() {
var amountinval = $("#amountin").val();
var amountoutval = $("#amountout").val();
var amountValue = $("#amountValue").val();

total = parseFloat(amountValue * (amountinval / amountoutval)).toFixed(2);
$('#totavalue').attr('placeholder', total);
}
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="currency-calc-in__input currency-calc__input col-lg-8 col-sm-6 col-md-6 col-6">
<label for="amountValue" class="currency-calc__label">Kwota (posiadam)</label>
<input type="number" class="form-control" id="amountValue" name="amountValue" aria-describedby="numberHelp" placeholder="100">
</div>

<select class="custom-select currency-calc-in__slick" id="amountin" name="amountin">
<option value="1" data-description="PLN" data-value="1" data-symbol="PLN">Polski złoty</option>
<option value="0.1286" data-description="THB" data-value="0.1286" data-symbol="THB">Bat tajlandzki</option>
<option value="4.1886" data-description="USD" data-value="4.1886" data-symbol="USD">Dolar amerykański</option>
<option value="2.6503" data-description="AUD" data-value="2.6503" data-symbol="AUD">Dolar australijski</option>
<option value="0.5406" data-description="HKD" data-value="0.5406" data-symbol="HKD">Dolar Hongkongu</option>
</select>

<select class="custom-select currency-calc-out__slick" id="amountout" name="amountout">
<option value="0.0003" data-description="IDR" data-value="0.0003" data-symbol="IDR">Rupia indonezyjska</option>
<option value="0.0549" data-description="INR" data-value="0.0549" data-symbol="INR">Rupia indyjska</option>
<option value="0.0034" data-description="KRW" data-value="0.0034" data-symbol="KRW">Won południowokoreański</option>
<option value="0.5920" data-description="CNY" data-value="0.5920" data-symbol="CNY">Yuan renminbi</option>
</select>

<div class="currency-calc-out__input currency-calc__input col-lg-8 col-sm-6 col-md-6 col-6">
<label for="amountValue" class="currency-calc__label">Kwota (otrzymam)</label>
<input type="number" class="form-control converter-score__value--normal" id="totavalue" placeholder="100" disabled>
<input type="number" class="form-control converter-score__value--js" id="totavalue" style="display:none;" placeholder="" disabled>
</div>

最佳答案

您是否尝试过用 cal() 函数替换此处的 console.log?

    $('.currency-calc-in__slick').ddslick({
imagePosition: "right",
selectText:"Wybierz",
onSelected: function (data) {

cal();
}
});

$('.currency-calc-out__slick').ddslick({
imagePosition: "right",
defaultSelectedIndex:3,
onSelected: function (data) {

cal();

}
});

关于javascript - .change jQuery 不改变数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61290356/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com