Jquery pop up prompt effect when deleting data records

  • 2020-03-30 02:50:45
  • OfStack

Prompt effect is shown as follows :(delete prompt box is always centered)
< img SRC = "border = 0 / / files.jb51.net/file_images/article/201405/201405061108308.gif? 20144611842 ">  
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<title> Prompt effect when deleting records </title> 
<style type="text/css"> 
body{ font-size:13px;} 
.divShow{ line-height:32px; height:32px; width:280px; background-color:#eee; padding-left:10px;} 
.divShow span{ padding-left:50px;} 
.dialog{ width:360px; border:solid 5px #666; position:absolute; display:none; z-index:101;} 
.dialog .title{ background-color:#fbaf15; padding:10px; color:#fff; font-weight:bold;} 
.dialog .title img{ float:right;} 
.dialog .content{ background-color:#fff; padding:25px; height:60px;} 
.dialog .content img{ float:left;} 
.dialog .content span{ float:left; padding-top:10px; padding-left:10px;} 
.dialog .bottom{ text-align:right; padding:10px 10px 10px 0px; background-color:#eee;} 
.mask{ width:100%; height:100%; background-color:#000; position:absolute; top:0px; left:0px; 
filter:alpha(opacity=30); z-index:100; display:none;} 
.btn{ border:solid 1px #666; padding:2px; width:65px; filter:progid.DXImageTransform.Microsoft.Gradient(GradientType=0,StartColorStr=#ffffff, 
EndColorStr=#ECE9D8);} 
</style> 
<script src="Scripts/jquery-1.4.1-vsdoc.js" type="text/javascript"></script> 
<script src="Scripts/jquery-1.4.1.js" type="text/javascript"></script> 
<script type="text/javascript"> 
$(function () { 
$("#Button1").click(function () { //Register delete button click event
$(".mask").show(); //Display background color
showDialog(); //Set the Top and Left of the prompt dialog box
$(".dialog").show(); //Displays the prompt dialog box
}); 
 
function showDialog() { 
var objW = $(window); //The current window
var objC = $(".dialog"); //dialog
var brsW = objW.width(); 
var brsH = objW.height(); 
var sclL = objW.scrollLeft(); 
var sclT = objW.scrollTop(); 
var cruW = objC.width(); 
var cruH = objC.height(); 
var left = sclL + (brsW - cruW) / 2; //Calculates the left margin when the dialog box is centered
var top = sclT + (brsH - cruH) / 2; //Calculates the top margin when the dialog box is centered
objC.css({ "left": left, "top": top }); //Set the location of the dialog on the page
} 
$(window).resize(function () { //Page window size change event
if (!$(".dialog").is(":visible")) { 
return; 
} 
showDialog(); //Set the Top and Left of the prompt dialog box
}); 
$(".title img").click(function () { //Register to close the image click event
$(".dialog").hide(); 
$(".mask").hide(); 
}); 
$("#Button3").click(function () { //Register the cancel button click event
$(".dialog").hide(); 
$(".mask").hide(); 
}); 
$("#Button2").click(function () { //Register the ok button click event
$(".dialog").hide(); 
$(".mask").hide(); 
if ($("input:checked").length != 0) { //If delete row is selected
$(".divShow").remove(); //Deletes a row of data
} 
}); 
}); 
</script> 
</head> 
<body> 
<div class="divShow"> 
<input type="checkbox" id="Checkbox" /> 
<a href="#"> This is a record that can be deleted </a> 
<span> 
<input type="button" id="Button1" class="btn" value=" delete "/> 
<input type="button" value=" contrast " /> 
</span> 
</div> 
<div class="mask"></div> 
<div class="dialog"> 
<div class="title"> 
<img src="Images/close.gif" alt=" Click to close " /> Prompt for deletion  
</div> 
<div class="content"> 
<img src="Images/delete.jpg" alt="" /> 
<span> Do you really want to delete the record? </span> 
</div> 
<div class="bottom"> 
<input type="button" id="Button2" value=" determine " class="btn" />   
<input type="button" id="Button3" value=" cancel " class="btn" /> 
</div> 
</div> 
</body> 
</html> 

Related articles: