正如你在我的例子中看到的,我有我的輸入文本的.minus
和.plus
類。所以當我點擊加號時,如果我點擊減號,我想添加數字值。我想從零開始加入(對不起,我的英語不好)如何使用js/jquery從下到上進行計數?
我的意思是我的最小值必須是:0
,我的最大值必須是:unlimited
或50
或500
我該怎麼做?
.count-box {
margin: 30px;
}
.count-box i {
font-size: 32px;
cursor: pointer;
font-weight: bold;
vertical-align: middle;
}
input[type="text"] {
text-align: center;
width: 30px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="count-box">
<h3>ADULT</h3>
<i class="plus">+</i>
<input type="text" value="1">
<i class="minus">-</i>
</div>
<div class="count-box">
<h3>CHILDREN</h3>
<i class="plus">+</i>
<input type="text">
<i class="minus">-</i>
</div>
<div class="count-box">
<h3>BABY</h3>
<i class="plus">+</i>
<input type="text">
<i class="minus">-</i>
</div>
<div class="total-box">
<h1>TOTAL:</h1> <span class="total-count"></span>
</div>
https://stackoverflow.com/help/how-to-ask – MFGSparka
「我最大價值必須是:無限或50或500「。那麼它是哪一個?你不能同時擁有所有3種可能性。你到目前爲止嘗試過什麼?至少您必須將事件處理程序添加到加號/減號按鈕。你可以谷歌如何做到這一點。 – ADyson
你嘗試過什麼嗎? –