Вот с выбранными
<!DOCTYPE html>
<html>
<head>
<script src='http://code.jquery.com/jquery-latest.js'></script>
<!--
<link rel='stylesheet type=text/css href=tmp.css' />
-->
<style type='text/css'>
</style>
<script type='text/javascript'>
</script>
</head>
<body>
<span>
<span class="itogo" value="120">120 руб<input type="checkbox" /></span>
<span class="itogo" value="123">123 руб<input type="checkbox" /></span>
<span class="itogo" value="23">23 руб<input type="checkbox" checked /></span>
<span class="itogo" value="34">34 руб<input type="checkbox" /></span>
<span class="itogo" value="45">45 руб<input type="checkbox" /></span>
<span class="itogo" value="56">56 руб<input type="checkbox" /></span>
<span class="itogo" value="65">65 руб<input type="checkbox" checked /></span>
<span class="itogo" value="76">76 руб<input type="checkbox" /></span>
<span class="itogo" value="57">57 руб<input type="checkbox" /></span>
</span>
<div><span id="summa">0</span></div>
<script type="text/javascript">
function summ(){
var summ = document.getElementById("summa");
var total = 0;
$('.itogo > input:checked').each(function() {
total += parseInt($(this.parentNode).attr('value'));
});
summ.innerHTML = total;
};
summ();
</script>
</body>
</html>
</html>
|