title: Javascript onClick function SyntaxError: expected expression, got '}'
body: <p>I am trying to pass a parameter from a onClick event using javascript but got a <code>undefined value error</code>, after reading from the questions here at SO and as suggested you need to add and escape the parameter by using <code>\'\</code> but when applying the solution i am getting the <code>SyntaxError: expected expression, got '}'</code> on execution, Any suggestions would be great! </p>
  
  <p>Here is my actual code.</p>
  
  <pre><code>rootRef.on("child_added", snap =&gt; {
  
     var valkey = snap.key;
     var name = snap.child("Name").val();
     var email = snap.child("Email").val();
  
     $('#table_body').append('&lt;tr&gt;&lt;td&gt;'+ name +'&lt;/td&gt;&lt;td&gt;'+ email +'&lt;/td&gt;&lt;td&gt;&lt;a onClick="deleteMe(' + "'" + valkey + "'" + ')"&gt;delete&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;');
  
  });
  
  function deleteMe(valkey){
      var cKey = valkey;
      console.log(cKey);
  
  }
  </code></pre>
  
  <p>Here is a code snippet similar to my problem.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>$(document).ready(function(){
  
  var valkey = "hello!";
  
  $('#table_body').append("&lt;a onClick='deleteMe(\'" + valkey + "\')'&gt;delete&lt;/a&gt;");
  
  
  function deleteMe(valkey){
      
      var cKey = valkey;
      
      console.log(cKey);
  
  }
  
  
  });</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"&gt;&lt;/script&gt;
  
  &lt;div id="table_body"&gt;
  
  &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>