 <p>Try using regex <code>/g</code></p> <pre><code>.replace(/'/g,"%%") </code></pre> <p>Change your code as below,</p> <pre><code>document.getElementById("Message").innerHTML = document.getElementById("Message") .innerHTML .replace(/'/g,"%%"); </code></pre>