我需要提取表中每列的詳細信息。例如,列“名稱/編號”。該表包含多個地址每行的最后一列都有一個按鈕,使用戶可以選擇列出的地址。問題:我的代碼僅拾取<td>具有類的第一個nr。我該如何工作?這是jQuery位:$(".use-address").click(function() { var id = $("#choose-address-table").find(".nr:first").text(); $("#resultas").append(id); // Testing: append the contents of the td to a div});表:<table id="choose-address-table" class="ui-widget ui-widget-content"> <thead> <tr class="ui-widget-header "> <th>Name/Nr.</th> <th>Street</th> <th>Town</th> <th>Postcode</th> <th>Country</th> <th>Options</th> </tr> </thead> <tbody> <tr> <td class="nr"><span>50</span> </td> <td>Some Street 1</td> <td>Leeds</td> <td>L0 0XX</td> <td>United Kingdom</td> <td> <button type="button" class="use-address" /> </td> </tr> <tr> <td class="nr">49</td> <td>Some Street 2</td> <td>Lancaster</td> <td>L0 0XX</td> <td>United Kingdom</td> <td> <button type="button" class="use-address" /> </td> </tr> </tbody></table>
單擊按鈕獲取表行的內容
慕沐林林
2019-12-09 14:14:32