简体   繁体   中英

How to get table cell value using jquery on row click and show the value to another table?

I want to build a view that get the value from html table and show the value to another table. I have search how to do it, but haven't found it yet.I have found a lots of way, but just getting the value. I am new in jquery and dont know how to do it. Please help me. Thanks

 $('#sourceTable tr').click(function() { $(this).clone().appendTo($('#destTable')); });
 td { border: 1px solid black; padding: 5px; } td:hover { cursor: pointer; }
 <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <table id="sourceTable"> <tr> <th>Source Table</th> </tr> <tr> <td>Row 1</td> </tr> <tr> <td>Row 2</td> </tr> <tr> <td>Row 3</td> </tr> </table> <table id="destTable"> <tr> <th>Dest Table</th> </tr> </table>

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