New member
- Joined
- Feb 8, 2023
- Messages
- 23
- Thread Author
- #1
I want to highlight the hex code in the text while typing it.
I have a code that looks for a hex code among the already written text and highlights it.
But I added this code to the onkeyup event and everything started to work incorrectly.
enter image description here
Each time the button is pressed, the highlight is superimposed on each other. Does anyone know a way to highlight the hex code in the text while it is being printed?
I have a code that looks for a hex code among the already written text and highlights it.
Code:
$(".hwt-highlights").each(function(){
var hex = /#([a-zA-Z0-9]+)/g;
var spanhex = '<mark style="background-color: #$1">#$1</mark>';
this.innerHTML = this.innerHTML.replace(hex, spanhex);
});
But I added this code to the onkeyup event and everything started to work incorrectly.
enter image description here
Each time the button is pressed, the highlight is superimposed on each other. Does anyone know a way to highlight the hex code in the text while it is being printed?