confirm用法

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<input type="button" value="删除" onclick="del()">
<script>
function del() {
if (confirm('确定要删除吗?')) {
alert('你按下了“确定”按钮!');
} else {
alert('你按下了“取消”按钮!');
}
}
</script>
</body>
</html>

原文地址:https://www.cnblogs.com/jiaqi818/p/12739814.html