日期:2014-05-16 浏览次数:20723 次
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<script language="javascript" type="text/javascript" src="jquery.js"></script>
<title></title>
</head>
<body>
<script type="text/javascript" language="javascript">
$(function(){
});
function calc() {
var total = 0;
$('.c').each(function () {
if ($(this)[0].checked == true) {
total = total + Number($(this).val());
}
});
alert(total);
}
</script>
<input type="checkbox" class="c" value="100" />$100
<input type="checkbox" class="c" value="50"/>$50
<input type="checkbox" class="c" value="150"/>$150
<input type="button" id="total" onclick="calc();" value="总价" />
<label id="lbl1"></label>
</body>
</html>