【发布时间】:2020-06-26 21:31:42
【问题描述】:
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() 显示所有值,但没有按预期工作
【问题讨论】:
-
你对这行有什么期望:
var valor = $('.numbers input').each(function(){$('.numbers input').val();});?或者换句话说:这条线没有多大意义,而且绝对不是你想要的。 -
我不明白你想做什么......