gpt4 book ai didi

javascript - 使用jquery获取单条记录

转载 作者:行者123 更新时间:2023-12-03 07:02:55 25 4
gpt4 key购买 nike

在 php 的 Foreach 循环中,我仅获得点击事件“product_title”和“email”。代码如下。

foreach($abs_records as $abs)
{
<tr>
<td><input type="checkbox" name="case[]" class="case" ></td>
<td><?php echo $abs['product_id']; ?></td>
<td><?php echo $abs['product_title']; ?></td>
<td><?php echo $abs['user_email']; ?></td>
<td class="send_mail_btn"><a href="javascript:void(0)" >Send</a></td>
</tr><?php
} ?>

使用 Jquery 单击“发送”,我将获得“Product_title”和“user_email”的单个时间值的结果

你能建议我吗?

谢谢。

最佳答案

向 td 元素添加一个类,如下所示:

<tr>
<td><input type="checkbox" name="case[]" class="case" ></td>
<td><?php echo $abs['product_id']; ?></td>
<td class="title"><?php echo $abs['product_title']; ?></td>
<td class="email"><?php echo $abs['user_email']; ?></td>
<td class="send_mail_btn"><a href="javascript:void(0)" >Send</a></td>
</tr>

您可以在 jQuery 中找到相关值:

$(document).on('click', '.send_mail_btn', function() {
var title = $(this).siblings('.title').html();
var email = $(this).siblings('.email').html();
console.log("Title: " + title);
console.log("Email: " + email);
});

关于javascript - 使用jquery获取单条记录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36952121/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com