title: String IndexOf and Replace in wysiwyg
body: <p>I'm trying to create a very simple <code>wysiwyg</code> editor (without colors), and I've tried creating the "end tag" to one of the beginning tags.</p>
  
  <p>I know that when I use value it won't work since it gets the whole value of the <code>textarea</code> so I tried using <code>string</code> using <code>indexOf</code> and <code>replace</code>.</p>
  
  <p>But it seems like the code doesn't work, I've researched about searching pirticular keywords (lets assume it <code>&lt;html&gt;</code>) in the <code>textarea</code> and replacing it with another (keyword: <code>&lt;html&gt; &lt;/html&gt;</code>)</p>
  
  <p><strong>JavaScript</strong></p>
  
  <pre><code>$(document).ready(function() {
      var textarea = document.getElementById('codeTextarea');
      textarea.keyup(function(e) {
          var str = textarea.value;
          if(str.indexOf('&lt;html&gt;') != -1){
              str.replace("&lt;html&gt;", "&lt;html&gt; &lt;/html&gt;");
          }
      });
  });
  </code></pre>
  
  <p><strong>HTML</strong></p>
  
  <pre><code>&lt;textarea id="codeTextarea"&gt;&lt;/textarea&gt;
  </code></pre>
  
  <p>How can I replace a particular string in a <code>textarea</code> with another string? (I.E: <code>&lt;html&gt;</code> will be replaced with <code>&lt;html&gt; &lt;/html&gt;</code>)</p>
  
  <p><strong>Notice</strong></p>
  
  <p>Please don't tell me use value because value can be <code>&lt;doctype&gt; &lt;html&gt;</code> and then the wanted code wont work.</p>