简体   繁体   English

如何使用javascript / jquery突出显示特定单词?

[英]How do I highlight specific words as they are written, with javascript/jquery?

I'm looking for a script whereas words written in my textarea beginning with a "#" is to be highlighted in realtime, as they are written. 我正在寻找一个脚本,而在我的文本区域中以“#”开头的单词在编写时将实时突出显示。 ex: The cutest #animals ever. 例如:有史以来最可爱的动物

Any help with this problem is appreciated. 感谢您提供有关此问题的任何帮助。 Thank you. 谢谢。

You can't highlight things in a textarea. 您不能突出显示文本区域中的内容。 So your question is probably moot. 因此,您的问题可能是有争议的。

You could I suppose recreate an input box using a div and capturing keystrokes but it would be a huge amount of work. 您可以假设使用div重新创建一个输入框并捕获击键,但这将是大量工作。

Or you could do like this site does: Type in the textarea, and show the result under it. 或者,您也可以像本网站一样:输入文本区域,并在其下显示结果。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用Javascript / jQuery在具有特定类的元素中找到特定单词? - How do I find specific words in elements with specific classes with Javascript/jQuery? 如何使用jQuery突出显示DIV的特定部分? - How do I highlight a specific part of a DIV using jQuery? 如何在jQuery / Javascript中删除此突出显示脚本 - How do i remove this highlight script in jQuery/Javascript 如何使用 HTML 和 Javascript 突出显示文本中的特定单词? - How to highlight specific words in a text using HTML and Javascript? Javascript / JQuery:如何统计用逗号分隔的单词? - Javascript / JQuery: How do I count the words separated with a comma? 如何突出显示 javascript 中的重叠词? - How to highlight overlapping words in javascript? 用黄色背景突出显示所有超过 8 个字符的单词。 如何在不使用 jQuery 的情况下仅使用 JavaScript 来解决这个问题? - Highlight all the words over 8 character long with a yellow background. How to do this question with only JavaScript without using jQuery? 如何突出显示javascript列表框项目? - How do I highlight a javascript listbox item? 如何在 html 中突出显示 contenteditable div 中的特定单词 - How to highlight specific words in contenteditable div in html 如何使用原始javascript正确突出显示单词? - how to correctly highlight words using original javascript?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM