简体   繁体   中英

how Do Dynamic Add a new row HTML table using Jquery in onclick last column

How To set Add Row On Click To last Column3 column

Here Is Example http://jsfiddle.net/83aqdd62/8/

在此处输入图片说明

http://jsfiddle.net/83aqdd62/8/ Here Example

Updated Fiddle

<table id="sampTable">
      <thead>
        <tr>
            <td>Column 1</td>
            <td>Column 2</td>
            <td>Column 3</td>

          </tr>
      </thead>
      <tbody>
         <tr>
              <td><input type="text"/></td>
              <td><input type="text"/></td>
             <td><input type="text"/></td>

         </tr>
          <tr>
              <td><input type="text"/></td>
              <td><input type="text"/></td>
              <td><input type="text"/></td>

         </tr>
      </tbody>
    </table>

Jquery

$('#sampTable tr td:last-child').on("click",function(){
   addRow();
});
function addRow(){
     $sampleRow = $(' <tr> <td><input type="text"/></td><td><input type="text"/></td> <td><input type="text"/></td></tr>');
    $sampleRow.find("td:last").click(function(){
       addRow();
    });
   $('#sampTable tbody').append($sampleRow);
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM