簡體   English   中英

單擊鏈接時使用 javascript 獲取表行的內容

[英]Fetch the contents of a table row using javascript when a link is clicked

我有一個動態表,並且在該表的一個屬性中我有編輯鏈接,如果單擊該鏈接,我想獲取與該鏈接相鄰的數據。

在此處輸入圖像描述

例如,如果我在第 2 行單擊 Edit,我應該能夠檢索 Demo User、demouser、demo@demo.com 和 User using javascript。

關鍵是訪問該,然后在該行內查找元素:

$('.your-link').click(function () {
    const row = $(this).closest('tr');
    const whatever = row.find('.whatever').text();
})

暫無
暫無

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

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