I’m trying to replace a period in a string to an underscore using the javascript .replace() function. For example, if the string was Project.Build, I would want it to become Project_Build. Unfortunately, the method isn’t currently doing that. The period continues to remain a period.
This line of code is trimming off all white space from the string. It is also replacing all spaces with underscores as well. This part is currently working.
var rowID = $.trim(new String(status.teamCityProject).toLowerCase().replace(/ /g, "_").replace(/\./g, '_')) + status.id;
$("tr#" + rowID + " td.status").html(status.status).css({ 'color': statusColor, 'font-weight': 'bolder' })
You should assign or update the modified string to the var and use it..
.replacewill not update the original text. (Also removed new String)DEMO