如何在删除前显示确认信息? [英] How to show a confirm message before delete?

查看:113
本文介绍了如何在删除前显示确认信息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在点击删除(这可能是一个按钮或一个图片)时收到确认消息。如果用户选择'确定',则删除完成,否则如果点击'取消'则不会发生任何事情。

我试着在按钮被点击时回应,但回声使我的输入框和文本框失去了他们的风格和设计。

>

  var result = confirm(要删除?); 
if(result){
//逻辑删除项目
}


I want to get a confirm message on clicking delete (this maybe a button or an image). If the user selects 'Ok' then delete is done, else if 'Cancel' is clicked nothing happens.

I tried echoing this when the button was clicked, but echoing stuff makes my input boxes and text boxes lose their styles and design.

解决方案

Write this in onclick event of the button:

var result = confirm("Want to delete?");
if (result) {
    //Logic to delete the item
}

这篇关于如何在删除前显示确认信息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆