58

Possible Duplicate:
JavaScript/jQuery HTML Encoding

I have html tags need to be encoded.

<b>test</b>

I need to encode it to :

&lt;b&gt;test&lt;/b&gt;

I am using escape, but it doesn't work.

document.write(escape("<b>test</b>"));

the result I got is

%3Cb%3Etest%3C/b%3E

this is not what I expected. is there another way to do html encode using javascript?

Community
  • 1
  • 1
qinking126
  • 10,525
  • 21
  • 70
  • 117

0 Answers0