Change Text Color If Match Found Automatically Javascript|html
i have a textarea where i want to change color automatically for example : this is my pen my friend as soon as i enter the above text the keyword=pen should become green color and
Solution 1:
No, you can't do this in a textarea or text input. Any CSS text-related property will affect the whole text within the the textarea/input, not just a word.
see for more info: Multicolor Text Highlighting in a Textarea or Text Input
Solution 2:
First, you'll need to detect changes on the text area. Look into element.addEventListener()
and the change
event. Then inspect the text from the text area. You have bunch of options for this, but the easiest one is string.includes()
. If it returns true
, call your function to turn the text green.
Post a Comment for "Change Text Color If Match Found Automatically Javascript|html"