title: Removing non-break-spaces in JavaScript
body: <p>I am having trouble removing spaces from a string. First I am converting the <em>div</em> to <code>text();</code> to remove the tags (which works) and then I'm trying to remove the &quot;<code>&amp;nbsp</code>&quot; part of the string, but it won't work. Any Idea what I'm doing wrong.</p>
  <pre><code>newStr = $('#myDiv').text();
  newStr = newStr.replace(/&amp;nbsp;/g, '');
  
  $('#myText').val(newStr);
  
  
  &lt;html&gt;
    &lt;div id = &quot;myDiv&quot;&gt;&lt;p&gt;remove&amp;nbsp;space&lt;/p&gt;&lt;/div&gt;
    &lt;input type = &quot;text&quot; id = &quot;myText&quot; /&gt;
  &lt;/html&gt;
  </code></pre>