For a better user experience, a reminder is given when the user deletes the article, prompting him to delete the article. The specific implementation code is as follows:
HTML code:
<a link= ' {: U (' athlete/del/', Array (' UID ' => $vo [' ID '])} ' href= ' javascript:void (0) ' name= ' {$vo. Name} ' class= ' Del "> Delete </a>
jquery Code:
<script type= "Text/javascript" >
$ (function () {
$ (". Del"). Click (function () {
var dellink=$ (this). attr ("link");
Confirm (' Are you really going to delete ' <b> ' +$ (This). attr ("name") + ' </b> '? ', ' warm prompt ', function (action) {
if (action = = ' OK ') {
Top.window.location.href=dellink;
}
});
return false;
});
});
</script>
Effect Chart:
In fact, the use of the Confirm function, this and jquery is not much of a judgment, I can also have a simpler approach to the following
The first type: The simplest JS delete confirmation, directly written in the link:
<a href= "" Javascript:if ("Confirm that you want to delete this content?") location= "del.asp?&areyou= Delete &id=1" "> Delete </a>
Second: Define a function, which has the advantage of repeating calls:
<script language= "JavaScript" >
function Del_sure () {
var gnl=confirm ("OK to delete?");
if (gnl==true) {
return true;
}else{
return false;
}
}
</script>
Call Method:
<a href= "del.asp?id=<%=rs (" id ")%>" onclick= "Javascript:del_sure ()" > Delete </a>