【发布时间】:2016-07-13 09:27:31
【问题描述】:
我正在使用这个插件来突出显示文本区域:
http://www.jqueryscript.net/text/jQuery-Based-Text-Highlighter-For-Textarea.html
$('textarea').textareaHighlighter({
matches: [
{
'match': ['hello','dear','this is a test', 'text to match'], // will check for this matches
'matchClass': 'match' // on matched text this class will be added
}
]
});
颜色出现了,但不是在好的地方,它没有检测到行尾。
当我激活调试模式时:
$('textarea').textareaHighlighter({
debug: true,
matches: [
{
'match': ['hello','dear','this is a test', 'text to match'], // will check for this matches
'matchClass': 'match' // on matched text this class will be added
},
{
'match': /([\%'])(?:(?=(\\?))\2.)*?\1/g,
'matchClass': 'tags'
}
]
});
【问题讨论】:
-
你能展示现场演示吗? jsfiddle ?
-
@FastSnail: 好的 :)
-
@FastSnail:我用链接演示更新帖子
-
它没有突出显示您输入的内容,因为它需要您输入的字符串,然后再次插入突出显示范围。您可以在 jsfiddle 中清楚地看到这种情况。我的建议是隐藏当前文本,然后在另一个区域显示这将否定您遇到的问题的更改。
-
还是一样,文字还在,只是透明而已。
标签: javascript jquery syntax-highlighting