密钥上的输入值乘以 [英] Multiply input value on keyup
本文介绍了密钥上的输入值乘以的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何将一个输入的值乘以2并将其保存到另一个输入?
How do I multiple the value of one input by 2 and save it to another input?
因此,当我输入10(例如)时,该值为第二个输入是20?
So when I type 10 (for example), the value of the 2nd input will be 20?
谢谢
推荐答案
两个输入字段
<input type="text" id="input-value" />
<input type="text" id="output-value" readonly />
还有一些简单的jQuery
var $output = $("#output-value");
$("#input-value").keyup(function() {
var value = parseFloat($(this).val());
$output.val(value*2);
});
这篇关于密钥上的输入值乘以的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文