Php 使用jquery确认编辑表单

Php 使用jquery确认编辑表单,php,html,jquery,jquery-confirm,Php,Html,Jquery,Jquery Confirm,我正在使用jquery confirm,我需要捕获我单击要编辑的元素的名称 jQuery和jQuery确认 <head> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jquery-confirm/3.3.2/jquery-confirm.min.css"> <script src="https://cdnjs.

我正在使用jquery confirm,我需要捕获我单击要编辑的元素的名称

jQuery和jQuery确认

<head>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jquery-confirm/3.3.2/jquery-confirm.min.css">
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js" integrity="sha512-bLT0Qm9VnAYZDflyKcBaQ2gg0hSYNQrJ8RilYldYQ1FxQYoCLtUjuuRuZo+fjqhx/qtq/1itJ0C2ejDxltZVFg==" crossorigin="anonymous"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-confirm/3.3.2/jquery-confirm.min.js"></script>
</head>

PHP

<?php
    $products = array(['name'=>'Balloon'],
        ['name'=>'Bike']);
?>

<table>
    <thead>
      <tr>
        <th>Name</th>            
        <th>Edit</th>
      </tr>
    </thead>    
    <tbody>
      <?php foreach($products as $prod) { ?>
        <tr>
          <td><?php echo $prod['name'] ?></td>
          <td><a class="edit" href="#">Edit Product</a></td>
        </tr>
      <?php } ?>
    </tbody>
</table>

名称
编辑
脚本

$('a.edit').confirm({
    content: '<input type="text" value="$ Name of the product.">'
});
$('a.edit')。确认({
内容:“”
});

Obs:写有“$Name of the product”的地方应该出现我点击的每个产品的名称。

你可以使用
this。$target
获取
a
标签,然后使用
最近('tr')。查找('td:eq(0)')。text()
get first
td
内容

演示代码
$('.edit')。确认({
内容:函数(){
//获取最接近的tr并找到get product name。。
返回“”
}
});

名称
编辑
Abc
Abcd
Abce

非常感谢您!!