2
누구든지 나를 도울 수 있는지 궁금합니다.여러 텍스트 상자를 추가하는 jQuery
일부 텍스트 상자 (동적 양, 3 일 수 있으며 30 일 수 있음)가있는 웹 페이지가 있으며 각 사용자는 숫자를 입력 할 수 있으며 하단에 총 개수가 있습니다.
$('input.qty').change(function() {
// Get the current total value
var total = $('#total');
// Update it with the changed input's value
total.val(parseInt(total.val()) + parseInt($(this).val()));
});
예 HTML : 현재
나는이가 잘 처음 추가하지만 당신이 값을 변경 시작할 때 단순히보다는 전체에 새로운 금액을 추가
<td><input type="text" class="qty" value="0" /></td>
<td><input type="text" class="qty" value="0" /></td>
<td><input type="text" class="qty" value="0" /></td>
<td><input type="text" id="total" value="0" /></td>
모든 상자를 추가합니다.
어떻게 정렬 할 수 있습니까? 아마 각 attr을 어떻게 든 사용합니까?