take a look at the example below
$(document).ready(function(){
$('#flights td').on('click', function(){
var colIndex = $(this).prevAll().length;
var rowIndex = $(this).parent('tr').prevAll().length + 1;
var cost = 0;
var sign = '';
for (var i = 0; i < rowIndex; i++)
{
var value = $('#flights tbody tr:eq(' + i.toString() + ') td:eq(' + (colIndex-1) + ')').html();
sign = value.substring(0,1);
cost += Number(value.substring(1));
}
$('#cost').text(sign + cost);
});
});
<table id="flights">
<thead>
<tr>
<th>Destination</th>
<th>First</th>
<th>Second</th>
<th>Third</th>
</tr>
</thead>
<tbody>
<tr>
<th>One</th>
<td>$400</td>
<td>$450</td>
<td>$500</td>
</tr>
<tr>
<th>Two</th>
<td>$450</td>
<td>$500</td>
<td>$550</td>
</tr>
<tr>
<th>Three</th>
<td>$500</td>
<td>$550</td>
<td>$600</td>
</tr>
<tr>
<th>Four</th>
<td>$550</td>
<td>$600</td>
<td>$650</td>
</tr>
<tr>
<th>Five</th>
<td>$600</td>
<td>$650</td>
<td>$700</td>
</tr>
</tbody>
</table>
<label>Cost: </label> <label id="cost"></label>
Explanation:
1- $('#flights td') - This is a jquery selector to get all the td(s) inside a table called "#flights" ---- you can find more about jquery selector Here
2- .on('click', function(){}) - Here I'm attaching a event handler function to a specific event which is the click ---- you can find more about .on() Here
3- var colIndex = $(this).prevAll().length; - Here I'm getting the column index of the CLICKED td ---- you can find more about .prevAll() Here
4- var rowIndex = $(this).parent('tr').prevAll().length + 1; - Here I'm getting the row index of the CLICKED td ---- you can find more about .parent() Here
5- for (var i = 0; i < rowIndex; i++) - Here I started a loop starting from 0 until the ROW INDEX OF THE CLICKED td ---- you can find more about for loop Here
6- var value = $('#flights tbody tr:eq(' + i.toString() + ') td:eq(' + (colIndex-1) + ')').html(); - Here I'm getting the value inside the td based on the STATIC COLUMN INDEX OF THE CLICKED td and the ROW INDEX (which is i) inside the loop. ---- you can find more about .html() Here
7- value.substring(0,1); - I'm just getting the Sign which may vary ($, €)
so that I can concatenate it in the cost label. ---- you can find more about .substring() Here
8- cost += Number(value.substring(1)); - Here I'm getting the value of each td and stripping out the sign and converting it to number and adding it to the total cost which will be populated in the cost label.
9- $('#cost').text(sign + cost); - Here just populating the total cost in the cost label and concatenating the Sign to it.
You can learn more about jquery from Here, it's a good start to learn.