我使用JQUERY Datatable js和SweetAlert.js
当单击ID获取ID并显示警告提示确认poppup时,数据表中有一个删除图标。当单击“是”时,它将删除正常工作。
我想获取有关警告消息内容中id =“ TITLE”值的信息。
数据表
<tbody>
<tr>
<td>@item.TITLE</td>
<td>
**<a href="javascript:void(0);" onclick="deleteuser('@item.id')"><i class="fa fa-trash-o"></i></a>**
</td>
</tr>
</tbody>
SWEETALERT Js 代码这里需要此点(粗体标记的值)=>文本:“您要删除@TITLE!” id标题文字应该在这里
function deleteuser(userid) {
swal({
title: "Are u sure?",
text: "@TITLE are u want delete!",
icon: "warning",
buttons: {
cancel: {
text: "No, iptal!",
value: null,
visible: true,
className: "",
closeModal: false,
},
confirm: {
text: "Yes, sil!",
value: true,
visible: true,
className: "",
closeModal: false
}
}
})
答案 0 :(得分:1)
您可以这样实现:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<form role="form" action="form-process.php" method="POST" id="contactForm">
<div class="input-group mb-3">
<label for="name"></label>
<div class="input-group-prepend"> <span class="input-group-text">Name</span> </div>
<input type="text" class="form-control" id="name" aria-label="First and last name.">
<div class="invalid-feedback">Required</div>
<div class="valid-feedback"></div>
</div>
<div class="input-group mb-3">
<div class="input-group-prepend"> <span class="input-group-text">Email</span> </div>
<input type="email" class="form-control" aria-label="Email address." id="email">
</div>
<div class="input-group mb-3">
<div class="input-group-prepend">
<button class="btn btn-outline-secondary dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Subject</button>
<div class="dropdown-menu"> <a class="dropdown-item" href="#">Music</a> <a class="dropdown-item" href="#">Programming</a> <a class="dropdown-item" href="#">Just saying hi!</a> </div>
</div>
<input type="text" class="form-control" aria-label="Subject" id="subject">
</div>
<div class="input-group">
<div class="input-group-prepend mb-3"> <span class="input-group-text">Message</span> </div>
<textarea class="form-control" id="message" aria-label="Email message."></textarea>
</div>
<button class="btn btn-outline-primary" id="form-submit" type="submit" data-dismiss="modal">Send</button>
</form>
稍后在javascript中
<tbody id="my-table">
<tr>
<td class="title">Some Title</td>
<td>
<a href="javascript:void(0);" class="delete-btn" data-id="@item.id"><i class="fa fa-trash-o"></i></a>
</td>
</tr>
</tbody>