title: Pass variable as parameter to onclick function using double and single quotes in .append JQuery
body: <p>I am trying to pass a variable as a parameter to onClick function using JQuery append. as the number of rows are uncertain I am using $.each to add a button at the end of each row which when clicked will edit that row.
  So to get that row i am passing the id of that row to the Onclick function in a button, I am confused with the quotes as the function is not working.</p>
  
  <p>Here is the code</p>
  
  <pre><code>$.each(result, function (key, item) {
                  $("#table1").append("&lt;tr&gt;&lt;td&gt;" + item.id + "&lt;/td&gt;&lt;td&gt;" + item.name + "&lt;/td&gt; &lt;td&gt;" + item.type + "&lt;/td&gt; &lt;td&gt;" + item.weight + "&lt;/td&gt; &lt;td&gt;" + item.birthday + "&lt;/td&gt; &lt;td&gt;" + item.hasHorns + "&lt;/td&gt;&lt;td&gt;&lt;input class='editR' id='" + item.id + "' type='button' value='EDIT' onclick='editRow('" + item.id + "')'/&gt; &lt;/td&gt; &lt;/tr&gt;");
              });
  </code></pre>
  
  <p>FUNCTION</p>
  
  <pre><code>function editRow(eid) {
  
      $("#table1").empty();
      //var eid = $(this).attr("id");
      alert(this);
      $.getJSON(uri + "GetByID/" + eid, function (data) {
          $("#headerType").replaceWith("&lt;h2&gt;Edit Animal&lt;/h2&gt;");
          $("#table1").append("&lt;tr&gt;&lt;td&gt;&lt;h4&gt;ID&lt;/h4&gt;&lt;/td&gt; &lt;td&gt;&lt;h4&gt;Name&lt;/h4&gt;&lt;/td&gt; &lt;td&gt;&lt;h4&gt;Type&lt;/h4&gt;&lt;/td&gt; &lt;td&gt;&lt;h4&gt;Weight&lt;/h4&gt;&lt;/td&gt; &lt;td&gt;&lt;h4&gt;Birthday&lt;/h4&gt;&lt;/td&gt; &lt;td&gt;&lt;h4&gt;Has Horns&lt;/h4&gt;&lt;/td&gt;&lt;/tr&gt;");
          $("#table1").append("&lt;tr&gt;&lt;td&gt;" + data.id + "&lt;/td&gt;&lt;td&gt;" + data.name + "&lt;/td&gt; &lt;td&gt;" + data.type + "&lt;/td&gt; &lt;td&gt;" + data.weight + "&lt;/td&gt; &lt;td&gt;" + data.birthday + "&lt;/td&gt; &lt;td&gt;" + data.hasHorns + "&lt;/td&gt; &lt;/tr&gt;");
      });
  }
  </code></pre>
  
  <p>RESULT on Browser Inspect element (Sorry i cannot post pics as it needs 10 impoession)</p>
  
  <pre><code>&lt;input class="editR" id="1" type="button" value="EDIT" onclick="editRow(" 1')'=""&gt;
  </code></pre>
  
  <p>everything works but nothing happens on click</p>
  
  <p>Thank you</p>