Hope this helps:
$("input[type=checkbox]").change(function(){
recalculate();
});
function recalculate(){
var sum = 0;
$("input[type=checkbox]:checked").each(function(){
sum += parseInt($(this).attr("rel"));
});
alert(sum);
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…