douyujun0152 2018-03-26 08:31
浏览 38

使用Javascript和jQuery确认删除

// function to get all categories from the db

function find_all_category(){

    global $connection;

    $query = "SELECT * FROM `category`"; //getting data from db 
        $get_cat_details = mysqli_query($connection, $query);
        while($row=mysqli_fetch_assoc($get_cat_details)) { // fetch-array
        $cat_id=$row['catid'];
        $cat_name=$row['catname'];
        echo "<tr>";
        echo "<td>{$cat_id}</td>";
        echo "<td>{$cat_name}</td>";
        echo "<td><a href='category.php?edit={$cat_id}'><i class='fa fa-pencil- 
               square-o' aria-hidden='true' style='color:purple;'></i></a> 
               </td>";      
        echo "<td><a class='item_delete' href='category.php?delete={$cat_id}'><i 
              class='fa fa-trash-o' aria-hidden='true' style='color:red;'></i> 
              </a></td>"; // contains class to be used in javascript
        echo "</tr>";
    }
}

//javascript function for the confirm function

$(".item_delete").click(function()
    return confirm("Are you sure you want to delete ?");
)};

Not working,please help

  • 写回答

2条回答 默认 最新

  • douling0053 2018-03-26 08:37
    关注

    There is a syntax error use below code. You missed the opening { of the function.

    $(".item_delete").click(function() {
        return confirm("Are you sure you want to delete ?");
    });
    
    评论

报告相同问题?

悬赏问题

  • ¥15 stm32代码移植没反应
  • ¥15 matlab基于pde算法图像修复,为什么只能对示例图像有效
  • ¥100 连续两帧图像高速减法
  • ¥15 组策略中的计算机配置策略无法下发
  • ¥15 如何绘制动力学系统的相图
  • ¥15 对接wps接口实现获取元数据
  • ¥20 给自己本科IT专业毕业的妹m找个实习工作
  • ¥15 用友U8:向一个无法连接的网络尝试了一个套接字操作,如何解决?
  • ¥30 我的代码按理说完成了模型的搭建、训练、验证测试等工作(标签-网络|关键词-变化检测)
  • ¥50 mac mini外接显示器 画质字体模糊