I have a live() function in my jquery below:
$("#qandatbl td.weight input").live("change", calculateTotal);
function calculateTotal()
{
var totalweight = hundred;
$("#qandatbl td.weight input").each(function (i, elm){
totalweight = totalweight - parseInt($(elm).val(), 10);
});
$("#total-weight").text(totalweight).append('%').css('font-weight', 'bold');
}
Now some people say that the live() function is slowing fading away and that is better to use the on() function. If this is true then how do I change the code above to on() function rather than a live() function? Is it important I don’t use live() or does it not really matter that much?
According to the documentation:
So in your case, if you’re using jQuery 1.7+, it would be: