日期:2014-05-16 浏览次数:20505 次
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript" src="Scripts/jquery-1.4.1.min.js"></script>
<script type="text/javascript">
$(function () {
var sum = 0;
$("#price div").each(function (i, k) {
sum += parseFloat($(this).html());
})
$(".totalprice").html(sum);
})
</script>
</head>
<body>
<form id="form1" runat="server">
<div id="price">
<div>100</div>
<div>150</div>
<div>180</div>
</div>
<div style="color:Red;" class="totalprice"></div>
</form>
</body>
</html>