How to escape single quote

Posted by Ravi on Stack Overflow See other posts from Stack Overflow or by Ravi
Published on 2010-03-11T20:52:45Z Indexed on 2010/03/11 20:59 UTC
Read the original article Hit count: 219

Filed under:

Hello All, How can I escape a ' (single quote) in JS. This is where I'm trying to use it.

<input type='text' id='abc' value='hel'lo'>

result for the above code is "hel" populated in the text box. I tried to replace ' with \' but this what I'm getting.

<input type='text' id='abc' value='hel\'lo'>

result for the above code is "hel\" populated in the text box.

How can I successfully escape the single quotes.

© Stack Overflow or respective owner

Related posts about html