title: Remove a word on click with Jquery and Regex
body: <p>I am looking for some help. I have found this script that sort of solves my problem 50% - I want to click on a word and delete the word using jquery similar to the example below. If using the example below it will highlight the word that you click on.</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
    &lt;style&gt;
    p { color:blue; font-weight:bold; cursor:pointer; }
    &lt;/style&gt;
  &lt;script type="text/javascript" src="/js/jquery-1.4.2.min.js"&gt;&lt;/script&gt;&lt;/head&gt;
  &lt;body&gt;
  
  &lt;p&gt;
    Once upon a time there was a man
    who lived in a pizza parlor. This
    man just loved pizza and ate it all 
    the time.  He went on to be the
    happiest man in the world.  The end.
  &lt;/p&gt;
  &lt;script&gt;
    var words = $("p:first").text().split(" ");
    var text = words.join("&lt;/span&gt; &lt;span&gt;");
    $("p:first").html("&lt;span&gt;" + text + "&lt;/span&gt;");
    $("span").click(function () {
      $(this).css("background-color","yellow");
    });
  &lt;/script&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>How would I delete/remove the word by clicking on it.</p>
  
  <p>I also found this sample to replace a word with a word.</p>
  
  <pre><code>var el = $('#id');
  el.html(el.html().replace(/word/ig, ""));
  </code></pre>
  
  <p>Is there anybody that can help me tie it together so that when I click on the word it replaces the word. It can also maybe replace the word with something like [Delete] and I can strip it out with a regex on a form submit?</p>
  
  <p>Ok I have sort of figured it out by replacing</p>
  
  <pre><code>$("span").click(function () {
          $(this).css("background-color","yellow");
        });
  
  $("span").click(function () {
      $(this).remove();
    });
  </code></pre>
  
  <p>This brings me to the next question.</p>
  
  <p>How can I update the results to a form text field?</p>
  
  <p>Updated example from tip below</p>
  
  <pre><code>  &lt;form id="form1" name="form1" method="post" action="spin1.php"&gt;
    &lt;p&gt;&lt;%=(Recordset1.Fields.Item("g_article_desc_spin").Value)%&gt;&lt;/p&gt;
  &lt;textarea name="myfield" id="myfield" onFocus="this.blur();" cols="45" rows="5"&gt;&lt;/textarea&gt;
  &lt;script&gt;
    var words = $("p:first").text().split(" ");
    var text = words.join("&lt;/span&gt; &lt;span&gt;");
    $("p:first").html("&lt;span&gt;" + text + "&lt;/span&gt;");
  $("span").click(function () { 
      $('myfield').val($(this).remove().parent('p').text()); 
  });  
  &lt;/script&gt; 
        &lt;input type="submit" name="button" id="button" value="Submit" /&gt;
    &lt;/form&gt;
  </code></pre>
  
  <p>I am still not sure how to update the value in myfield</p>