原始字符串 var sourceText="";
sourceText有很多种情况。 比如:
情况1: sourceText="Where there is great love, <span style="color: #0000ff; font-weight: bold;">there</span> are always miracles.";
情况2:sourceText="Where there is great love, <span style="color: #0000ff; font-weight: bold;">there</span> <span style="color: #0000ff; font-weight: bold;">
are</span> always miracles.";
情况3:...
需要处理的字符串:there are always
现在的需求是: 从原始字符串中找到需要处理的字符串,然后高亮加黄色背景显示。但是原始字符串里可能所有的单词都已经被加粗和加字体颜色,这样直接找"there are always"这个字符串是找不到的。需要处理的字符串可能是一个单词,也可能是一个句子。
以sourceText为情况2和需要处理的字符串是there are always举例, 需要得到的结果是:Where there is great love, <span style="background-color:yellow;font-we;ight:inherit;"><span style="color: #0000ff; font-weight: bold;">there</span> <span style="color: #0000ff; font-weight: bold;">
are</span> always</span> miracles.
跪求大神不吝赐教!!!
能帮忙写出code最佳!!!
一下午没弄出来,实在是没招了!!!
在线等,
Help me...
狐的传说
红糖糍粑
千巷猫影
翻阅古今
宝慕林4294392
智慧大石
跃然一笑
繁花不似锦
隔江千里
SMILET
相关分类