How to make a function handler for the event?

$(".tovar #doscen").each(function(){

 summ += parseInt($(this).html(), 10) ;
$('#skolko').html(summ+'Tg');
$("#cenazakaza").html(summ+'Tg');

});

it is necessary that this function has always worked to monitor change in the basket and summed up the prices how can it be done?
July 9th 19 at 11:05
3 answers
July 9th 19 at 11:07
timer you can. setInterval()
not suitable and close - Lottie_Streich commented on July 9th 19 at 11:10
July 9th 19 at 11:09
Will help you a callback
The function that should be invoked to implement the primary function.

The idea is that the buttons adding/deleting products in the shopping cart was equipped with such colback
July 9th 19 at 11:11
Problem solved
$(".doska").bind( 'DOMSubtreeModified',function(){ // track the content change unit 2
 var summ = 0;
 $(".tovar #doscen").each(function(){

 summ += parseInt($(this).html(), 10) ;
 $('#skolko').html(summ +'Tg');
 $("#cenazakaza").html(summ +'Tg');
console.log($(this).text())

});
});

Find more questions by tags jQuery