国产探花免费观看_亚洲丰满少妇自慰呻吟_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);
?>

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

圖片精選

主站蜘蛛池模板: 安平县| 福州市| 德保县| 渑池县| 青海省| 扎兰屯市| 泗水县| 乌海市| 巴青县| 平原县| 于田县| 定襄县| 永新县| 洱源县| 黔江区| 峨眉山市| 剑河县| 基隆市| 嵩明县| 滨州市| 泰安市| 阿拉善盟| 治多县| 法库县| 新宁县| 马鞍山市| 双柏县| 中西区| 武宣县| 甘德县| 石河子市| 仁化县| 专栏| 东宁县| 砀山县| 浦江县| 佛教| 扶沟县| 兴安县| 东辽县| 绥江县|