Ok, basically I am currently building a kind of script editor, and I want smart highlighting, so as the user types I want to highlight specific words and symbols.
I also want this to be realtime.
So as the user types the innerHTML property is updated using the string replace method. So say I want to change all 'me' s with '<span style="color:wh ite">me</span>'
I would use:
The only problem with this offcourse is, that as you type, every me will get another set of tags, so after 3 edits after a me has been replaced, the html will end up as:
So I need to know how to basically say "If a span isn't already around this portion of the string add a span, otherwise do not match the regular expression".
Thanks, Josh
I also want this to be realtime.
So as the user types the innerHTML property is updated using the string replace method. So say I want to change all 'me' s with '<span style="color:wh ite">me</span>'
I would use:
Code:
editable_div.innerHTML = editable_div.innerHTM.replace(/me/gi, "<span style=\"color:white\">me</span>");
Code:
<span style="color:white"><span style="color:white"><span style="color:white">me</span></span></span>
Thanks, Josh
Comment