javascript - Is there any plug-in related to text highlighting in the input box? Can you recommend it?
迷茫
迷茫 2017-05-19 10:16:27
0
1
616

To create a keyword search function

迷茫
迷茫

业精于勤,荒于嬉;行成于思,毁于随。

reply all(1)
漂亮男人

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'); 

Example

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!