title: Function to escape quotes in JavaScript
body: <p>to start off, I don't do much JavaScript and am a complete newbie at it, now that's out of the way.. I've got a slight problem I'm trying to escape quotes from users inputs in my search app:</p>
  
  <pre><code>function getQString()
  {
  var query_str = 'q=' + $('input[name=q]').val().trim();
  return  query_str;
  }
  </code></pre>
  
  <p>This is done as a method within a gsp file, is there something equivalent to .escape() in JavaScript?</p>
  
  <p>This query is later sent to elastic search and gives me hell due to the quotes especially input like a"b..</p>
  
  <p>I'm using ES 0.20.6</p>