jQuery确认删除与onclick问题 [英] JQuery confirm delete with onclick issue

查看:99
本文介绍了jQuery确认删除与onclick问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的确认快讯方块指令码:

This is my confirm alert box script:

$(document).ready(function(){
    $('.confirm').click(function(){
        var answer = confirm("Are you sure you want to delete this item?");
        if (answer){
            return true;
        }
        else
        {
            return false;
        }

    });
});

我的链接是

 <span class='button-content confirm' onclick= \"location.href='delet-project.php?id={$row['project_id']}';\"

问题是它删除record.Even我给cancel.I调用jquery使用

The problem is it delete the record.Even i gave cancel.I call the jquery by using the class confirm.Any help would be appreciated.

推荐答案

我对我的一个web站点使用了相同的功能, Facebook类型的对话系统,我发送代码示例,从它,请从我的代码,一个想法(对不起,没有时间在代码中设置您的参数,所以我发送在我的项目中使用的原始代码)

I used the same functionality for one of my webistes, where I was making the facebook type conversation system, I am sending the code example from it, please get an idea from my code, (sorry, don't have time to set your parameters in the code, so am sending the original code used in my project).

javascript功能:

The javascript function:

<script language="javascript">
function ConfirmDelete(id)
{
    var result = confirm("Are you sure you want to Delete this Conversation ?");
    if (result==true)
    {
        window.location = "index.php?page=inbox&delete_conversation="+id;
    }
}
</script>

HTML,显示会话的标题,并显示X按钮确认后,该X对话将被删除。

HTML, where the title of the conversation is displayed, and an X button is displayed, by clicking on that X button the conversation will be deleted after the confirmation.

<h2>
   <a href='javascript:ConfirmDelete(<?php echo $conversation['id']; ?>);'>[x]</a>
   <a href="index.php?page=view_conversation&amp;conversation_id=<?php echo $conversation['id']; ?>"><?php echo $conversation['subject']; ?></a>
</h2>

这篇关于jQuery确认删除与onclick问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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