javascript - how to highlight part of textarea html code -


I want to get a dragon version web regexbox, and I get a problem, different colors (switch yellow and In the middle of the blue) there is a demo which I actually want, but I was a newbie on JS, I did not understand the meaning of his code. Any advice is appreciated

alt text

There is a pre element on a textarea, so when you write something, apply it to some filter Copying input to pre element.

For example:

  & lt; Pre id = "view" & gt; & Lt; / Pre & gt; & Lt; Textarea id = "code" & gt; & Lt; / Textarea & gt; When you type on  #code , this is copying the value, applying filters and adding HTML to  #view  .  P> 
  var code = document.getElementById ("code"); Var pre = document.getElementById ("Pre"); (Code) .onkeyup = function () {val = this.value; Val = Your Reggae (Val); (East). WinnerHTML = val; }; There will be a way of matching   

YourRegex a regex and some parsed content on pre Will return, allowing to customize the appearance of textarea (which is actually an element above it).

  function YourRegex (val) {// This function adds color, bold, whatever you need. If (/bbcc/i.test("bbcc ")) return" & lt; b & gt; "+ val +" & lt; / b & gt; "; }  

Comments