var valor = $('.numbers input').each(function(){$('.numbers input').val();});
$(valor).click(function(){
$('input#icms').val(valor);
});
<div class="numbers">
<input type="button" id="number0" value="0">
<input type="button" id="number1" value="1">
<input type="button" id="number2" value="2">
<input type="button" id="number3" value="3">
<input type="button" id="number4" value="4">
<input type="button" id="number5" value="5">
<input type="button" id="number6" value="6">
<input type="button" id="number7" value="7">
<input type="button" id="number8" value="8">
<input type="button" id="number9" value="9">
<input type="button" id="point" value=".">
</div>
<input type="text" class="calc" id="icms" value="" placeholder="CUSTO + ICMS">
我将使用上面的输入从输入[type = button]接收值。Console.log()向我显示所有值,但无法正常工作
在每个输入类型按钮上附加单击事件。然后使用this
关键字附加单击按钮的值以进行输入。