title: Can we use getSelection and document.selection for spotting a word to delete it?
body: <p>Can we use getSelection and document.selection for spotting a word to delete it? Is it possible to use them for this? The following code helps select words and put them in an array but the selected words remain in the text.</p>
  <pre><code>&lt;script&gt;
  let container;
  var arr = [];
  function get_selection() {
  
   var txt = '';
      if (document.getSelection) {
         txt = document.getSelection().toString();
               
               
           } 
  
           else if (document.selection) {
               txt = document.selection.createRange().text;
           }
            arr.push(txt);
           }
           }
          document.getElementById(&quot;txt&quot;).onclick = get_selection;
  
  &lt;/script&gt;
  </code></pre>