开发者

Easiest way to find duplicate content in string

I want to use Johann Burkard's jQuery highlight plugin to highlight a term called "stack" in a div. But the开发者_JAVA百科re are more than one "stack" strings found in the div. I need to highlight only the first instance of this string. How to avoid the duplicate string using jquery?


<div id='div1'>
stack stack
<div>

$('#div1').html($('#div1').text().replace('stack','<span style="background-color:blue">stack</span>'));
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜