国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 語言 > JavaScript > 正文

jquery 漂亮的刪除確認和提交無刷新刪除示例

2024-05-06 15:54:52
字體:
來源:轉載
供稿:網友
jquery 漂亮的刪除確認和提交無刷新刪除,本例數據庫結構很簡單,就一個字段就行了,具體的實現代碼如下,感興趣的朋友可以參考下

本例數據庫結構很簡單,就一個字段就行了

jquery 漂亮的刪除確認和提交無刷新刪除示例

 
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 += '<a href="#">'+name+'<span></span></a>';
if(!obj.action){
obj.action = function(){};
}
});
var markup = [
'<div>',
'<div>',
'<h1>',params.title,'</h1>',
'<p>',params.message,'</p>',
'<div>',
buttonHTML,
'</div></div></div>'
].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

復制代碼 代碼如下:


<div>
<?php
require "conn.php";
$sql="select * from `add_delete_record` where id>0";
$rs=mysql_query($sql);
if ($row = mysql_fetch_array($rs))
{
do {
?>
<div>
<a href="#" >
<?php echo $row['text']?>
</a>
<div></div>
</div>
<?php
}
while ($row = mysql_fetch_array($rs));
}?>
</div>


JavaScript Code

復制代碼 代碼如下:


$(document).ready(function(){
$('.item .delete').click(function(){
var elem = $(this).closest('.item');
var id=$(this).attr('id');
$.confirm({
'title' : '刪除該記錄?',
'message' : '您確認刪除該記錄? <br />刪除后無法恢復記錄.',
'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

復制代碼 代碼如下:


<?php
require "conn.php";
$id=$_GET['id'];
$delete_small_sql = "delete from add_delete_record where";
$result_small = mysql_query($delete_small_sql);
?>

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表

圖片精選

主站蜘蛛池模板: 高阳县| 万盛区| 荥阳市| 和政县| 大英县| 中江县| 贡嘎县| 莲花县| 荥阳市| 黄浦区| 汝州市| 神木县| 板桥市| 桦甸市| 建瓯市| 嘉鱼县| 年辖:市辖区| 威海市| 阳原县| 牟定县| 唐河县| 伊吾县| 台州市| 镇原县| 宜昌市| 保德县| 丹江口市| 江门市| 三原县| 塘沽区| 绥棱县| 合肥市| 莱阳市| 岱山县| 紫云| 武威市| 铜梁县| 灌南县| 奇台县| 宁化县| 东乡县|