-1

我想知道是否可以在第二次单击时忽略 jQuery 函数的执行,以便我可以创建传递,但只有当用户在确认单击时单击“是”时。我有显示确认框,但无法找到一种方法来做到这一点。

$(function()
{    
    $(".msgbox-confirm").live("click", function(e)
    {
        e.preventDefault();

        $.msgbox("Are you sure you want to permanently delete this element?", {
            type: "confirm",
            buttons: [
                { type: "submit", value: "Yes" },
                { type: "submit", value: "No" }
            ]
        }, function(result)
        {
            if (result == "Yes") {
                // passthrough code goes here!
            }
        });
    });
});
4

1 回答 1

-1

你可以为你的元素使用.unbind()方法,这样下次它就不会启动了。

    $(".msgbox-confirm").unbind("click");
于 2014-03-02T14:38:28.227 回答