<!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> <title>Jquery实现第一列选中项的计算</title> <mce:script type="text/javascript" src="jquery-1.4.2.min.js" mce_src="jquery-1.4.2.min.js"><!-- // --></mce:script> <mce:script type="text/javascript"><!-- $(function(){ var res=0; $("#test").bind("click",function(){ $("input[type=checkbox]").each(function() { if($(this).is(":checked")) { var v=$(this).parent().next().text(); res+=parseFloat(v); } } ) alert(res); $("input[type=checkbox]").attr("checked",false); }) }) // --></mce:script> </head> <body> <table width="200" border="1"> <tr> <td><input type="checkbox" class="checkbox" /></td> <td>22.3</td> <td>23.4</td> <td>12.4</td> </tr> <tr> <td><input type="checkbox" class="checkbox" /></td> <td>22.1</td> <td>33.1</td> <td>33.4</td> </tr> <tr> <td><input type="checkbox" class="checkbox" /></td> <td>11.1</td> <td>22.4</td> <td>34.5</td> </tr> </table> <input type="button" id="test" value="总和" /> </body> </html>