xxxxxxxxxx
<html lang="en">
<head>
<meta charset="utf-8">
<title>JavaScript Replace Character in a String</title>
<script>
function strReplace(){
var myStr = 'quick_brown_fox';
var newStr = myStr.replace(/_/g, "-");
// Insert modified string in paragraph
document.getElementById("myText").innerHTML = newStr;
}
</script>
</head>
<body>
<p id="myText">quick_brown_fox</p>
<button type="button" onclick="strReplace();">Replace</button>
</body>
</html>