title: I need to write a variable's value(which will hold the value present in table td) to the textbox dynamically using edit button in jquery
body: <p>I have the following code/function in jquery to create a table row dynamically,which will contain the button edit in td of the table tr and it is to be used to intitate a function onclick which will pass its row's values to the form fields which i have created.</p>
  
  <pre><code> function addRow() {
          debugger;
          var table = $('#basicTable');
          var row = $('&lt;tr&gt;&lt;/tr&gt;').appendTo(table);
          $('&lt;td&gt;&lt;/td&gt;').text($('#txt1').val()).appendTo(row);
          $('&lt;td&gt;&lt;/td&gt;').text($('#txt2').val()).appendTo(row);
          $('&lt;td&gt;&lt;/td&gt;').text($('#txt3').val()).appendTo(row);
          $('&lt;td&gt;&lt;input type="button" id="btnedit" value="Edit" /&gt;&lt;/td&gt;').appendTo(row);
          $('&lt;td&gt;&lt;input type="button" id="btndel" value="Delete" class="rem" /&gt;&lt;/td&gt;').appendTo(row);
          $("#form").trigger('reset');
  
          return table;
      }
  </code></pre>
  
  <p>while below is the jquery code which gets called when the click event is initiated for the edit button:</p>
  
  <pre><code>  $("#btnedit").click(function () {
                  debugger;
                  var par = $(this).parent().parent(); 
                  var tdName = par.children("td:nth-child(1)");
                  var tdEmail = par.children("td:nth-child(2)");
                  var tdPhone = par.children("td:nth-child(3)");
                 $("#txt1").val(tdName).html();
  
                 $("#txt2").val(tdEmail);
                 $("#txt3").val(tdPhone);
  
  
              });
  </code></pre>
  
  <p>But when i run the code using debugger and check for the value contained in the varaible tdName it shows like this: <code>[&lt;td&gt;Kamal Singh&lt;/td&gt;]</code> and in the textbox it shows like [object,object],also i need one of the textbox to be focused so as to update the details.</p>