Js simple implementation of the deletion of records when the prompt effect

  • 2020-03-30 00:43:19
  • OfStack

<style type="text/css"> 
.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; 
.btn {border:#666 1px solid;padding:2px;width:65px; 
filter:progid:DXImageTransform.Microsoft.Gradient(GradientType=0,StartColorStr=#ffffff, EndColorStr=#ECE9D8);} 


<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 curW = objC.width(); 
var curH = objC.height(); 
//Calculates the left margin when the dialog box is centered
var left = sclL + (brsW - curW) / 2; 
//Calculates the top margin when the dialog box is centered
var top = sclT + (brsH - curH) / 2; 
//Set the location of the dialog on the page
objC.css({ "left": left, "top": top }); 

$(window).resize(function() {//Page window size change event
if (!$(".dialog").is(":visible")) { 
showDialog(); //Set the Top and Left of the prompt dialog box

$(".title img").click(function() { //Register to close the image click event

$("#Button3").click(function() {//Register the cancel button click event

$("#Button2").click(function() {//Register the ok button click event
if ($("input:checked").length != 0) {//If delete row is selected
$(".divShow").remove(); //Deletes a row of data

<div class="divShow"> 
<input id="Checkbox1" type="checkbox" /> 
<a href="#"> This is a erasable record </a> 
<input id="Button1" type="button" value=" delete " class="btn" /> 
<div class="mask"></div> 
<div class="dialog"> 
<div class="title"> 
<img src="Images/close.gif" alt=" Click to close " /> Prompt for deletion  
<div class="content"> 
<img src="Images/delete.jpg" alt="" /><span> Do you really want to delete this record? </span> 
<div class="bottom"> 
<input id="Button2" type="button" value=" determine " class="btn"/>   
<input id="Button3" type="button" value=" cancel " class="btn"/> 

Related articles: