84669 person learning
152542 person learning
20005 person learning
5487 person learning
7821 person learning
359900 person learning
3350 person learning
180660 person learning
48569 person learning
18603 person learning
40936 person learning
1549 person learning
1183 person learning
32909 person learning
To create a keyword search function
业精于勤,荒于嬉;行成于思,毁于随。
If it’s just a very ordinary highlight. . . You can do this:
.hl { background-color: yellow; }
<p class="search-result">搜索结果: SegmentFault ( www.sf.gg ) 是中国领先的开发者社区。 我们希望为中文开发者提供一个纯粹、高质的技术交流平台, 与开发者一起学习、交流与成长,创造属于开发者的时代!</p>
function light($sel, keyword, hightLightClass){ var text = $sel.html(); var temp = text.split(keyword).join(`<span class="${hightLightClass}">${keyword}</span>`); $sel.html(temp); } light($('.search-result'), '交流', 'hl');
If it’s just a very ordinary highlight. . . You can do this:
Example