: How to highlight certain words with jQuery

前端 未结 2 1755
醉酒成梦
醉酒成梦 2020-12-22 04:20

I\'m looking for a script than can highlight a certain number of words depending on their position. example, for the following contentI want to highlight only the second, th

2条回答
  •  我在风中等你
    2020-12-22 04:33

    This jQuery plugin is what you're looking for:

    • jQuery Highlight

    It does exactly what you want, traverses the DOM TextNodes and looks for the text to search, when it find one occurrence it creates an span element.

    Usage :

    $('p').highlight('bibendum sem ut'); 
    

提交回复
热议问题