如何转义单引号? [英] How can I escape a single quote?

查看:83
本文介绍了如何转义单引号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在HTML中转义'(单引号)?

How can I escape a ' (single quote) in HTML?

这是我要使用的地方:

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

以上代码的结果为"hel".填充在文本框中.我试图用 \'替换',但这就是我要得到的.

The 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'>

以上代码的结果为"hel".填充在文本框中.

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

如何成功转义单引号?

推荐答案

您可以使用HTML实体:

You could use HTML entities:

  • &#39; 表示'
  • &#34; 表示"
  • ...

有关更多信息,您可以查看 HTML中的字符实体引用 .

For more, you can take a look at Character entity references in HTML.

这篇关于如何转义单引号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆