//函数从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函数
$(".item_delete").click(function()
return confirm("Are you sure you want to delete ?");
)};
不工作,请帮忙
答案 0 :(得分:1)
在代码下面使用语法错误。你错过了函数的开头{
。
$(".item_delete").click(function() {
return confirm("Are you sure you want to delete ?");
});
答案 1 :(得分:0)
你应该在像这样的变量
中有确认值$('body').on('click', '.item_delete', function() {
return confirm("Are you sure you want to delete ?"); // if you just want
// to return the confirm
// or you can delete based on conditions as
var statusDelete = confirm("Are you sure you want to delete ?");
if(statusDelete == "true"){
// call function to delete
}
if(statusDelete == "false"){
// call function when cancel clicked
}
};