Jquery插入Unicode而不是符号 [英] Jquery inserting unicode instead of symbol
问题描述
我正在寻找一种方法来制作一个非常基本的所见即所得,例如当用户点击按钮时,它会插入符号 ♂ (♂)
i'm looking in a way to make a really basic wysiwyg such as when a user lick the button, it insert the symbol ♂ (♂)
它正在工作,但有两个问题:1 - 仅插入 unicode 字符,它们不会转换为符号 (♂)
It is working but there is two problem :
1 - Only the unicode characters are inserted, they are not converted into symbol (♂)
2- 如果您有时间,是否有一种简单的方法可以在文本光标"所在的位置而不是在 textarea 内容的末尾插入符号?
2- If you have time, is there a simple way to insert the symbol where the "text cursor"is and not at the end of the content of the textarea ?
感谢您的帮助
推荐答案
♂
是一个 HTML 转义码.
仅在 HTML 源代码中处理.
♂
is an HTML escape code.
It is only processed in HTML source.
Javascript 字符串文字使用它们自己的转义码:'\u2642'
(代码点为十六进制而不是十进制).
您也可以直接使用字符:'♂'
.(这要求您正确设置文件编码)
Javascript string literals use their own escape code: '\u2642'
(with the code point in hexadecimal rather than decimal).
You can also just use the character directly: '♂'
. (this requires that you set your file encodings correctly)
这篇关于Jquery插入Unicode而不是符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!