jQuery(function() {
var MarketCapTotal = 0;
// loop through the table
jQuery('#grdWatchlistname tbody tr').each(function() {
// replace the dollar signs and commas
var MarketCap = (jQuery('td:nth-child(4)', jQuery(this)).html
().replace('$', '').replace(/[^a-zA-Z 0-9]+/g, ''));
var td4th = jQuery('td:nth-child(4)', jQuery(this));
if (!isNaN(MarketCap)) {
MarketCapTotal += parseInt(MarketCap);
}
alert(MarketCapTotal);
});
});
Also, your parseInt() function really should specify the radix you want.
You can get some unforseen issues if you don't. So,
MarketCapTotal += parseInt(MarketCap);
would become
MarketCapTotal += parseInt(MarketCap, 10);
Hope that helps.