Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок0
Hello! Is there any way to color keywords inside a <textarea> tag?
My idea is to create a programming environment in a textarea. I mean color strings, keywords etc. Anyone can help please?
5 ответов
+ 1
I had the same idea before, but I wasn't able to find a solution.
The only thing I was able to come up with was reading the textareas content and then replacing the words with html span elements that csn be colored using css.
The resulting text is then being innerHTMled to a preview element.
+ 1
yes but you cant change the cursor position
0
Jakob Meier Thank you for the answer. Yes, I have an idea to do it like that. I viewed many online colored text editors, and I'm trying to clone them. I was interested in an easier way :)
0
the only problem is that you cannot really click on the text to edit it - you still have to edit the text in the textarea
0
Jakob Meier :/ Yes, but in JS there is a focus function, so when you click the text, it can say InvisibleTextare.focus()