用Java编写乘法

问题描述 投票:0回答:1

我需要将priceMonthly乘以30,如何在此“如果”函数中执行此操作?我正在使用它来回显输入的数字,但我需要将该数字乘以30。剂量有人认为过高,或者有人可以指导我为什么它不起作用?

function keyup_fill(ele, ele_place) {
    $(ele).on("keyup", function(event) {

        if ( $(ele).attr("name") === "priceMonthly" ) {
            if (!$.isNumeric($(ele).val())) {
                return ($(ele).val()*30); //not working
            }
        }

      var newText = event.target.value ;
        $(ele_place).html(newText); 
    });
}


keyup_fill("#priceMonthly", "#priceMonthly-place");
javascript multiplying
1个回答
1
投票

如果要在#priceMonthly-place中显示的结果是在#priceMonthly中输入的值乘以30的结果,则可以使用代码进行此操作(请注意,我假设两个ID都代表输入元素):

function keyup_fill(ele, ele_place) {
    $(ele).on("keyup", function(event) {
        // I'm assuming that `ele` is an input.
        var value = $(this).val();
        if ($.isNumeric(value)) {
            // I'm assuming that ele_place is an input.
            $(ele_place).val(value * 30);
        }
    });
}

keyup_fill("#priceMonthly", "#priceMonthly-place");
© www.soinside.com 2019 - 2024. All rights reserved.