0

Javascript how to search text and highlight it

Javascript how to search text and highlight it How can i hightlight the text by using replace method? Like .replace("desired input","<mark>

amp;<_mark>"); **the mark part doesnt work, how to fix it Or is there any other method i can make it highlighted

18th Apr 2022, 12:45 PM
Jacky
10 Respuestas
+ 3
Look for more in Code Playground, if you want ... https://code.sololearn.com/Wo51gndh7Kfa/?ref=app
18th Apr 2022, 12:58 PM
Ipang
+ 3
Post the full code or atleast complete code snippet related to problem.. As it already stated may you are using inner text value.. Or see @ipang example,
18th Apr 2022, 1:55 PM
Jayakrishna 🇮🇳
20th Apr 2022, 2:41 PM
Calviղ
Calviղ - avatar
+ 1
But currently my code is printing out `<mark>
amp;</mark>` instead of highlighting
18th Apr 2022, 1:45 PM
Jacky
+ 1
Sorry just to check is it the texarea cannot be highlighted? Like i input some random text, then i find and highlight
18th Apr 2022, 2:34 PM
Jacky
+ 1
Is it doesnt work for textarea?
18th Apr 2022, 2:35 PM
Jacky