title: how do you do html encode using javascript?
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/1219860/javascript-jquery-html-encoding">JavaScript/jQuery HTML Encoding</a>  </p>
  </blockquote>
  
  
  
  <p>I have html tags need to be encoded.</p>
  
  <pre><code>&lt;b&gt;test&lt;/b&gt;
  </code></pre>
  
  <p>I need to encode it to :</p>
  
  <pre><code>&amp;lt;b&amp;gt;test&amp;lt;/b&amp;gt;
  </code></pre>
  
  <p>I am using escape, but it doesn't work.</p>
  
  <pre><code>document.write(escape("&lt;b&gt;test&lt;/b&gt;"));
  </code></pre>
  
  <p>the result I got is </p>
  
  <pre><code>%3Cb%3Etest%3C/b%3E
  </code></pre>
  
  <p>this is not what I expected. is there another way to do html encode using javascript?</p>