<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<script src="新建文件夾/jquery-1.9.1.min.js" type="text/javascript"> </script>
<script>
$(function(){
var t = $(".text_box");
$(".add").click(function(){
var t=$(this).parent().find('input[class*=text_box]');
t.val(parseInt(t.val())+1)
setTotal();
})
$(".reduce").click(function(){
var t=$(this).parent().find('input[class*=text_box]');
t.val(parseInt(t.val())-1);
if(parseInt(t.val())<1){
t.val(1);
}
setTotal();
})
function setTotal(){
var s=150;
$(".cartTable").each(function(){
s+=parseInt($(this).find('input[class*=text_box]').val())*parseFloat($(this).find('td[class*=price]').text());
});
$(".Money").html(s.toFixed(2));
}
setTotal();
})
</script>
<div class="searchNone_box cartBox">
<div class="searchNonebox">
<div class="searchNonePosi scrollBox100">
<div class="searchNone_head BuyBox"></div>
<div class="searchNone_scroll scrollBoxHeight">
<div class="close cartCloss"></div>
<span class="cart_icon"></span>
<table id="cartTable">
<thead>
<tr>
<th>
<label>
<input class="checkAll" id="checkAll" type="checkbox" onclick="selectAll(this);"/> 全選
</label>
</th>
<th>..</th>
<th>...</th>
<th>價格</th>
<th>數量</th>
<th>金額</th>
<th>操作</th>
</tr>
</thead>
<tbody>
<tr>
<td class="checkbox">
<input class="checkOne" type="checkbox"/>
</td>
<td class="goods">
....
</td>
<td class="Ship_station">.....</td>
<td class="price">¥150</td>
<td class="count">
<input class="reduce" type="button" value="-" />
<input class="text_box" type="text" value="1" />
<input class="add" type="button" value="+" />
</td>
<td class="Money">¥150</td>
<td class="operation">
<span class="delete">
x 刪除<br />
</span>
</td>
</tr>
</tbody>
<tbody>
<tr>
<td class="checkbox">
<input class="checkOne" type="checkbox"/>
</td>
<td class="goods">
....
</td>
<td class="Ship_station">...</td>
<td class="price">¥150</td>
<td class="count">
<input class="reduce" type="button" value="-"/>
<input class="text_box" type="text" value="1"/>
<input class="add" type="button" value="+" />
</td>
<td class="Money">¥150</td>
<td class="operation">
<span class="delete">
x 刪除<br />
</span>
</td>
</tr>
</tbody>
</table>
<ul class="Total_pic">
<li class="Total">總計:¥ 150,000,00</li>
<li class="Clearing">
<input type="button" value="立即結算">
</li>
</ul>
</div>
更正下。。
function setTotal() {
var s = 150, total = 0
$("#cartTable tr:gt(0)").each(function () {
s = parseInt($(this).find('input[class*=text_box]').val()) * parseFloat($(this).find('td[class*=price]').text().replace('¥', ''));
$(".Money", this).html(s.toFixed(2));
total += s;///////
});
$('.Total').html(total);//
}