繁体   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