Javascript 如何将所选行的值传递给弹出警报?

Javascript 如何将所选行的值传递给弹出警报?,javascript,php,jquery,html,sweetalert2,Javascript,Php,Jquery,Html,Sweetalert2,我有一张由值组成的表。所以每一行都有重复的按钮。当用户按下复制按钮时,它会将值发送到sweetalert2弹出窗口。但是,它没有得到值。我已经在sweetalert的文本中调用了{{{item->description}},但它没有传递值?怎么通过呢?我在复制按钮处传递{{item->id},但它不起作用 html 向复制按钮链接添加更多数据属性(数据描述),并从中删除重复的id(id=“delete1”),无需:- <a class="duplicatePlanRecord btn bt

我有一张由值组成的表。所以每一行都有重复的按钮。当用户按下复制按钮时,它会将值发送到sweetalert2弹出窗口。但是,它没有得到值。我已经在sweetalert的文本中调用了
{{{item->description}}
,但它没有传递值?怎么通过呢?我在复制按钮处传递
{{item->id}
,但它不起作用

html


向复制按钮链接添加更多数据属性
(数据描述)
,并从中删除重复的id
(id=“delete1”)
,无需:-

<a class="duplicatePlanRecord btn btn-xs btn-danger" data-id="{{ $item->id }}" data-description="{{ $item->description }}" href="javascript:void(0);">Duplicate</a>

注意:-如果
'try id'
'try desc'
不起作用,则使用
'try'+id
'try'+desc
。也可以从其他链接中删除重复的
(id=“delete”)

您可以在代码段上执行此操作吗?id必须唯一您可以在每个链接上重复
id=“delete”和
id=“delete1”
row@MisterJojo但是我根本不用身份证。我只使用数据id传递它。此时,
text:'try{{{$item->description}}}
,您是否应该引用单击元素的
上的
数据id
?在代码中留下错误是次要的?它可以工作。非常感谢你。有一天我应该请你吃巧克力
有一天我应该请你吃巧克力
->我在等待。顺便说一句,很高兴帮助你。祝你今天愉快……)
$( ".duplicatePlanRecord" ).click(function(e) {

   Swal.fire({
   title: 'Are you sure to duplicate the plan?',
   text: 'try {{$item->description}}',
   input: 'text',
   inputAttributes: {
       autocapitalize: 'off'
   },
   showCancelButton: true,
   confirmButtonText: 'Look up',
   showLoaderOnConfirm: true,
   preConfirm: (login) => {
       return fetch(`//api.github.com/users/${login}`)
           .then(response => {
              if (!response.ok) {
                throw new Error(response.statusText)
              }
              return response.json()
            })
        .catch(error => {
          Swal.showValidationMessage(
            `Request failed: ${error}`
          )
        })
    },
<a class="duplicatePlanRecord btn btn-xs btn-danger" data-id="{{ $item->id }}" data-description="{{ $item->description }}" href="javascript:void(0);">Duplicate</a>
$( ".duplicatePlanRecord" ).click(function(e) {
    var id = $(this).data('id'); //get id
    var desc = $(this).data('description'); //get description
    Swal.fire({
        title: 'Are you sure to duplicate the plan?',
        text: 'try id', // or use 'try desc'
        .... rest of the code