How to highlight text using javascript

后端 未结 13 2230
名媛妹妹
名媛妹妹 2020-11-22 02:32

Can someone help me with a javascript function that can highlight text on a web page. And the requirement is to - highlight only once, not like highlight all occurrences of

13条回答
  •  伪装坚强ぢ
    2020-11-22 02:56

    Since HTML5 you can use the tags to highlight text. You can use javascript to wrap some text/keyword between these tags. Here is a little example of how to mark and unmark text.

    JSFIDDLE DEMO

提交回复
热议问题