[jQuery] Get Sum Of Inputs With Class X

I’ve got a form and am using jquery to create row total for about 5 rows. This allows the user to input a qty and part number and then fills out the rest of the information (product name, msrp, dealer cost).

If all of the row total (qty * price) have a class of say class=“rowTotal” is there a quick and easy way of getting the sum of all these classes?


This worked great.

function calculateSum() {
			var sum = 0;
			//iterate through each textboxes and add the values
			$(".row_total").each(function() {
				//add only if the value is number
				if(!isNaN(this.value) && this.value.length!=0) {
					sum += parseFloat(this.value);
			//.toFixed() method will roundoff the final sum to 2 decimal places