【发布时间】:2014-07-21 10:02:24
【问题描述】:
假设我的页面有以下内容:
<p>This is the first sentence</p>
<p>This is the 2nd sentence. This is the third.</>
如果我双击“This is the first sentence”中的“This”,我想突出显示(将其背景颜色更改为黄色)“This”一词的出现
如果我双击“This is the 2nd sentence”中的“This”,我想突出显示它并继续显示任何已经创建的突出显示。
如果我在“This is the first sentence”中双击“This”在突出显示后我想将其背景颜色更改回原来的颜色并继续显示任何已经创建的突出显示。
如果我双击“第三个”。我要突出显示“第三”
我已经看到了很多关于如何使用 jQuery 执行此操作的示例,但它们最终会突出显示所选单词的所有出现。所以在上面的例子中,如果我点击“This is the first sentence”中的“This”,那么所有出现的“This”都会被突出显示。
有人知道如何只突出显示双击的单词吗?
【问题讨论】:
标签: jquery jquery-plugins