var x = "<div class="abcdef">"; x = x.replace(/"/g, '"'); document.body.appendChild( document.createTextNode("After: " + x) );