简体   繁体   中英

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

I have a dynamic table and in one of the attributes of that table I have edit link, I want to fetch the data adjacent to that link if that link is clicked.

在此处输入图像描述

For example if I click Edit on line number 2, I should be able to retrieve Demo User, demouser, demo@demo.com and User using javascript.

The key is to access the row and then find elements inside that row:

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

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