Possible Duplicate:
Fastest method to replace all instances of a character in a string
I have this
<p id="demo">/,\,:,*,?,",<,>,|</p>
<input type="button" onclick="myFunction()" value="Replace"/>
function myFunction() {
var str = document.getElementById("demo").innerHTML;
var n = str.replace(",", ", ");
document.getElementById("demo").innerHTML = n;
}
What I want is to replace this "/,\,:,*,?,",<,>,|"
with this "/, \, :, *, ?, ", <, >, |"
but what I get is this "/, \,:,*,?,",<,>,|"
.
What am I doing wrong ??