how to clear value comma separated last values in jquery code example Example: remove last comma from string javascript str = str.replace(/,\s*$/, "");