title: Replacing spaces with underscores in JavaScript?
body: <p>I'm trying to use this code to replace spaces with _, it works for the first space in the string but all the other instances of spaces remain unchanged. Anybody know why?</p>
  
  <pre><code>function updateKey()
  {
      var key=$("#title").val();
      key=key.replace(" ","_");
      $("#url_key").val(key);
  }
  </code></pre>