数据列表循环求和
<span class="price">¥<em>1.80</em></span> <span>白色</span> <span class="price">¥<em>1.50</em></span> <span>白色</span> <span class="price">¥<em>8.80</em></span> <span>白色</span> <div class="totalPrice ">总价:<em></em></div> <script> var sum = 0; $(".price em").each(function(e, el) { sum += $(this).text(); }); $(".totalPrice em").text("¥" + sum +"元") </script>