我想在文本区域中突出显示一个特定的单词。我知道如何对整个部门执行此操作,但不知道如何针对某个特定的单词执行此操作。
document.getElementById("labnol").style.backgroundColor = "lightblue";这就是我试图强调的整个div .But现在要做的是一个特定的单词。
发布于 2014-04-08 18:05:09
您必须使用类ui-match(可以是任何类名)为该单词创建span元素
HTML
<p>
Hello <span class="ui-match">there</span>, How are you?
</p>CSS
.ui-match {
background: #FF0;
}https://stackoverflow.com/questions/22932826
复制相似问题