If I use the below code I am able to highlight the found text in Window.
window.find(str);
But if I search for another string with window.find()
the previous highlight will be removed. But how can I change that to not remove old highlights..
You can use document.execCommand()
to add styling to the current selection after calling window.find()
. See my answer here, for example:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.