I don't know if this is the issue, but in the code you have posted, you don't call the calculateSum
function when #removeitem
is clicked. You are calling calculateTotal
, which is a non-existant function.
Your function should look something like this:
$(document).on('click', '#removeitem', function() {
calculateSum();
});
As a side note, you should limit the number of functions bound directly to the document
object. #removeitem
is an id, so there should only be 1 item with that ID. You should change your code to look like below, or that click event will be fired every time you click something on the page:
$('#removeitem').on('click', calculateSum);
If #removeitem
is supposed to appear more than once on your page, I would suggest changing to a class rather than an ID. An ID is only supposed to appear on the page once. Classes can appear multiple times. To use delegated events on classes, you could bind to the closest non changing parent element.
$('#parent').on('click', '.removeitem', calculateSum);