我有兩套這樣的輸入字段,可以通過類區分的:jQuery:如何從相應數組的每個文本輸入字段中減去數字值?
<div>
<input type="text" class="columnone" />
<input type="text" class="columnone" />
<input type="text" class="columnone" />
</div>
<div>
<input type="text" class="columntwo" />
<input type="text" class="columntwo" />
<input type="text" class="columntwo" />
</div>
必要驗證到位,以確保只有整數值可以由用戶在這些字段被輸入。
如何從在.columnone
相應的字段上change()
在特定.columntwo
文本字段中的值中減去每個輸入字段的.columntwo
價值?空值應該被視爲零。
例如,在第一輸入字段change()
在columntwo
,從第一場中.columntwo
減去在.columntwo
第一輸入字段的值。其他領域保持不變。
在此先感謝!
難道你不希望添加的類'columnone'和'columntwo'到包裝div,而不是每個輸入元素? – 2011-05-24 07:14:55