簡體   English   中英

如何在行單擊時使用 jquery 獲取表格單元格值並將值顯示到另一個表格?

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

我想構建一個從 html 表中獲取值並將值顯示到另一個表的視圖。 我已經搜索了如何做到這一點,但還沒有找到它。我找到了很多方法,但只是獲得了價值。 我是 jquery 的新手,不知道該怎么做。 請幫我。 謝謝

 $('#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>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM