Javascript Tips and Tricks
- by ybbest
1. Replace all , in one Javascript string.
var totalAmount= "100,000,000,000";
var find= ","; //Replace the first , with the empty string
var replace="";
totalAmount= totalAmount.replace(find,replace);
alert(totalAmount);
var totalAmount2= "100,000,000,000";
var newFind=/,/g //Replace all , with empty string
totalAmount2= totalAmount2.replace(newFind,replace);
alert(totalAmount2);