$('#btnAdd').bind('click', function () {
var qty = $('#txtQty').val() != '' ? parseInt($('#txtQty').val()) : 0;
var sum = $('#hiddenText').val() != '' ? parseInt($('#hiddenText').val()) : 0;
var total = qty + sum;
$('#hiddenText').val(total);
alert($('#hiddenText').val());
})
<input type="button" id="btnAdd" value="加入" />
按鈕btnAdd利用JS語法,Bind 住 Click事件
參考資料:
http://stackoverflow.com/questions/6458840/on-input-change-event