<!DOCTYPE html>
<html>
<head>
<title>Untitled</title>
<meta charset="utf-8">
<style type="text/css">
tr td:last-child, #out{
border: 1px solid #0000FF;
}
</style>
</head>
<body>
<table><tr><td id="ob1">2</td><td id="cena1">2</td><td id="summa1">4</td></tr>
<tr><td id="ob2">1.1</td><td id="cena2">0.2</td><td id="summa2">0.22</td></tr>
<tr><td id="ob3">2</td><td id="cena3">3</td><td id="summa3">6</td></tr>
<tr><td id="ob4">2</td><td id="cena4">5</td><td id="summa4">10</td></tr>
<tr><td id="ob5">2</td><td id="cena5">2</td><td id="summa5">4</td></tr>
<tr><td id="ob6">1</td><td id="cena6">1</td><td id="summa6">1</td></tr>
</table>
<output id="out"></output>
<script>
const tds = document.querySelectorAll('table tbody tr td:last-child');
let sum = 0;
for(const {textContent} of tds) sum += Number(textContent);
out.textContent = sum;
</script>
</body>
</html>
|