在JavaScript中询问是/否问题的代码
时间:2020-03-05 18:41:22 来源:igfitidea点击:
我只能找到提供确定/取消按钮的函数" confirm()"。有没有办法提供"是/否"按钮?
解决方案
回答
不。
相反,我们可以使用浏览器中的模式弹出窗口。
回答
Javascript提供了3个模式框。 "提示","确认"和"提醒"。这些都不满足要求。
有大量的js模态弹出式解决方案。这是一个例子。
- 模态框
回答
不,但是有JavaScript库可以为我们完成此任务。仅作为示例,Ext JS可用于创建消息框对话框。
回答
就像上面的其他每个人所说的那样,我们使用confirm()
来执行OK / Cancel。
我想推荐这个jQuery插件:jqModal。我在最近的3个项目中使用了它,并且对每个项目都效果很好。具体检查一下这个例子:。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。
6). FUN! Overrides -- a. view (alert), b. view (confirm) It is now time to show a real-world use for jqModal -- overriding the standard alert() and confirm dialogs! Note; due to the single threaded nature of javascript, the confirm() function must be passed a callback -- it does NOT return true/false.