title: Replace all \" with \\" in javascript
body: <p>I want to replace all <code>\"</code> in my string with <code>\\"</code> (<code>\"</code> in <code>&lt;div style=\"font-size:0.9em\"&gt;</code>)</p>
  
  <pre><code>var str = '{"CarID":"Z100","alerts":[{"AlertType":"Head &lt;b&gt;southeast&lt;/b&gt; on &lt;b&gt;Tân Hải&lt;/b&gt; toward &lt;b&gt;Trường Chinh&lt;/b&gt;&lt;div style=\"font-size:0.9em\"&gt;Pass by nhan cuoi dep (on the right)&lt;/div&gt;"}],"customizedLocations":[]}';
  
  str = str.replace(/\"/g, '\\\\"');
  </code></pre>
  
  <p>I want the output is (<code>\"</code> in <code>style</code> is replaced by <code>\\"</code>):</p>
  
  <p><code>{"VehicleID":"Z100","alerts":[{"AlertType":"Head &lt;b&gt;southeast&lt;/b&gt; on &lt;b&gt;Tân Hải&lt;/b&gt; toward &lt;b&gt;Trường Chinh&lt;/b&gt;&lt;div style=\\"font-size:0.9em\\"&gt;Pass by nhan cuoi dep (on the right)&lt;/div&gt;"}],"customizedLocations":[]}</code></p>
  
  <p>But actually I get is (ALL <code>"</code> is replaced by <code>\\"</code>):</p>
  
  <p><code>{\\"VehicleID\\":\\"Z100\\",\\"alerts\\":[{\\"AlertType\\":\\"Head &lt;b&gt;southeast&lt;/b&gt; on &lt;b&gt;Tân Hải&lt;/b&gt; toward &lt;b&gt;Trường Chinh&lt;/b&gt;&lt;div style=\\"font-size:0.9em\\"&gt;Pass by nhan cuoi dep (on the right)&lt;/div&gt;\\"}]}</code></p>
  
  <p>I don't want to use jQuery, can somebody help me!</p>