尊重劳动成果,转载请注明出处(http://blog.csdn.net/sllailcp/article/details/41113275)...
下面是批量获取单元格里面的数据。并对它进行操作。
完整案例:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<script type="text/javascript" src="jquery-1.9.1.min.js"></script>
</head>
<body>
<table class="table table-bordered bor bg_fff">
<thead>
<tr class="bg_00a3cb">
<th>规格ID</th>
<th>ERP编码</th>
<th>厂家编码</th>
<th>商品规格</th>
<th>市场价格</th>
<th>含票价格</th>
<th>不开票价</th>
</tr>
</thead>
<tbody id="zkj">
<tr>
<td>1</td>
<td>42</td>
<td>21</td>
<td>11</td>
<td>123</td>
<td>234</td>
<td>456</td>
</tr>
<tr>
<td>1</td>
<td>42</td>
<td>21</td>
<td>11</td>
<td>321</td>
<td>432</td>
<td>654</td>
</tr>
</tbody>
</table>
<select name="saleprice" class="inline input-small" id="salepro" onchange="tt()">
<option value="100">原价</option>
<option value="98">9.8折</option>
<option value="95">9.5折</option>
<option value="92">9.2折</option>
<option value="90">9折</option>
<option value="88">8.8折</option>
<option value="85">8.5折</option>
<option value="80">8折</option>
<option value="75">7.5折</option>
<option value="70">7折</option>
</select>
<script type="text/javascript">
var tArray = new Array();
for(var x=0;x<$('#zkj tr').length;x++){
tArray[x]=new Array()
for(var y=4;y<7;y++){
tArray[x][y]=$('#zkj tr:eq('+x+') td:eq('+y+')').html();
}
}
function tt() {
var aa = document.getElementById('salepro');
var price=aa.value;
price=parseInt(price)
for(var x=0;x<$('#zkj tr').length;x++){
for(var y=4;y<7;y++){
$('#zkj tr:eq('+x+') td:eq('+y+')').html(tArray[x][y]*price/100)
}
}
}
</script>
</body>
</html>
效果如图: