在确认框中显示是和否按钮而不是确定和取消? [英] Display Yes and No buttons instead of OK and Cancel in Confirm box?

查看:182
本文介绍了在确认框中显示是和否按钮而不是确定和取消?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能重复:

如何在javascript中创建是/否/取消框而不是ok / cancel?

在确认消息框中,如何将按钮更改为是和否而不是确定, 取消?有没有办法使用jQuery / Javascript实现这一目标?在此先感谢您的帮助。

In a Confirm message box, how can I change the buttons to say "Yes" and "No" instead of "OK" and "Cancel"? Is there some way to accomplish this using jQuery/Javascript? Thanks in advance for any help.

推荐答案

创建您自己的确认框:

<div id="confirmBox">
    <div class="message"></div>
    <span class="yes">Yes</span>
    <span class="no">No</span>
</div>

创建自己的 confirm()方法:

function doConfirm(msg, yesFn, noFn)
{
    var confirmBox = $("#confirmBox");
    confirmBox.find(".message").text(msg);
    confirmBox.find(".yes,.no").unbind().click(function()
    {
        confirmBox.hide();
    });
    confirmBox.find(".yes").click(yesFn);
    confirmBox.find(".no").click(noFn);
    confirmBox.show();
}

用你的代码打电话:

doConfirm("Are you sure?", function yes()
{
    form.submit();
}, function no()
{
    // do nothing
});

您需要在样式中添加CSS并正确定位确认框。

You'll need to add CSS to style and position your confirm box appropriately.

工作演示: jsfiddle.net/Xtreu

这篇关于在确认框中显示是和否按钮而不是确定和取消?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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