I have multiple textboxes (with class txtsum) which should allow only numbers. How can I calculate the sum of all these textboxes as the user types in the textbox
var $txtb = $(':input.txtsum');
$txtb.on('change',function(){
tot = 0.0;
$txtb.each(function() {
tot += parseFloat($(this).text());
});
});
Can you suggest me the right/better way to do it? Here’s what I tried http://jsfiddle.net/DPe4W/
Change
to
You should use
.valto get the value of any input elements likeinput,select.Also I changed your code like below,
DEMO: http://jsfiddle.net/DPe4W/7/