Answers:
":"
您可以使用'(在IE中比较困难)或'(应该可以在任何地方使用)。有关完整列表,请参见W3C HTML5命名字符引用或WebPlatform.org上的HTML实体表。
在HTML上下文中,您需要使用HTML来表示该字符。对于HTML,您需要使用数字字符引用 '('十六进制):
<input type='text' id='abc' value='hel'lo'>
context of html?
&表示字符引用的开始。
使用javascript内置函数转义和转义
例如
var escapedData = escape("hel'lo");
output = "%27hel%27lo%27" which can be used in the attribute.
again to read the value from the attr
var unescapedData = unescape("%27hel%27lo%27")
output = "'hel'lo'"
如果您要在属性中使用大量json字符串化数据,这将很有帮助
escape不是Unicode安全的。该规范建议不要使用它。