I have a simple function:
var total = 0.00;
$("#basket .txt").each(function() {
total += parseFloat($(this).html());
});
$('#total').text('Total: ' + total.toFixed(2));
That is used in 3 places on a script. How do I turn it into a function that can be called in the relevant places a bit like:
getTotal();
rather than use the "first" code above in each of the 3 places.
Thanks in advance