jquery漂亮的删除确认和提交无刷新删除示例_jquery
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了jquery漂亮的删除确认和提交无刷新删除示例_jquery,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含1744字,纯文字阅读大概需要3分钟。
内容图文
![jquery漂亮的删除确认和提交无刷新删除示例_jquery](/upload/InfoBanner/zyjiaocheng/319/86a84b26f19541d397e04c5611de60d3.jpg)
![jquery漂亮的删除确认和提交无刷新删除示例_jquery - 文章图片](/upload/getfiles/0001/2021/4/22/20210422101702654.jpg)
jquery.confirm.js
(function($){
$.confirm = function(params){
if($('#confirmOverlay').length){
// A confirm is already shown on the page:
return false;
}
var buttonHTML = '';
$.each(params.buttons,function(name,obj){
// Generating the markup for the buttons:
buttonHTML += ''+name+'';
if(!obj.action){
obj.action = function(){};
}
});
var markup = [
'
'
'
',params.title,'
','
',params.message,'
','
buttonHTML,
'
].join('');
$(markup).hide().appendTo('body').fadeIn();
var buttons = $('#confirmBox .button'),
i = 0;
$.each(params.buttons,function(name,obj){
buttons.eq(i++).click(function(){
// Calling the action attribute when a
// click occurs, and hiding the confirm.
obj.action();
$.confirm.hide();
return false;
});
});
}
$.confirm.hide = function(){
$('#confirmOverlay').fadeOut(function(){
$(this).remove();
});
}
})(jQuery);
PHP Code
require "conn.php";
$sql="select * from `add_delete_record` where id>0";
$rs=mysql_query($sql);
if ($row = mysql_fetch_array($rs))
{
do {
?>
}
while ($row = mysql_fetch_array($rs));
}?>
JavaScript Code
$(document).ready(function(){
$('.item .delete').click(function(){
var elem = $(this).closest('.item');
var id=$(this).attr('id');
$.confirm({
'title' : '删除该记录?',
'message' : '您确认删除该记录?
删除后无法恢复记录.',
'buttons' : {
'Yes' : {
'class' : 'blue',
'action': function(){$.ajax({
type: 'GET',
url: 'del.php',
data: 'id='+id,
});
elem.slideUp();
}
},
'No' : {
'class' : 'gray',
'action': function(){} // Nothing to do in this case. You can as well omit the action property.
}
}
});
});
});
del.php
require "conn.php";
$id=$_GET['id'];
$delete_small_sql = "delete from add_delete_record where id='$id'";
$result_small = mysql_query($delete_small_sql);
?>
内容总结
以上是互联网集市为您收集整理的jquery漂亮的删除确认和提交无刷新删除示例_jquery全部内容,希望文章能够帮你解决jquery漂亮的删除确认和提交无刷新删除示例_jquery所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。