title: calling function with 2 parameters onclick
body: <p>I want to call a function from a dynamically created element which contains 2 parameters, but it is sending it as only only parameter by merging the two.</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>$("#click").click(function(){
    var td = document.createElement('div');
    var num1 = 10;
    var num = 5;
    td.innerHTML = "new";
    $(td).attr('onclick','updateDistance("'+num1+','+num+'")');
    document.getElementById("div1").appendChild(td);
  })
  
  function updateDistance(id,distance){
    alert(id+","+distance);
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.1/jquery.min.js"&gt;&lt;/script&gt;
  &lt;div id = "div1"&gt;
    Text here
  &lt;/div&gt;
  &lt;button id = "click"&gt;CLick here&lt;/button&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>please help</p>