JQuery search in static HTML page with highlighting of found word

前端 未结 6 779
我在风中等你
我在风中等你 2020-12-02 19:11

I\'ve been trying to make a simple search inside a static HTML page using JQuery. I have to mention that this is just my first time working with JQuery.

I\'m trying

6条回答
  •  無奈伤痛
    2020-12-02 19:29

    (for one thing you want to use Background-Color, not Color, for background)

    I would create a css class for normal and a seperate (inherited) css class for highlighted text, and then use the JQuery to change the css class when you find what you are looking for.

    Just my initial thoughts though, not sure if there is a better way of doing it.

    EDIT: if you want to change only a specific word, you'll have to modify innerHTML to put it in a seperate tag at that point.

提交回复
热议问题