- xml - AJAX/Jquery XML 解析
- 具有多重继承的 XML 模式
- .net - 枚举序列化 Json 与 XML
- XML 简单类型、简单内容、复杂类型、复杂内容
我有一个 SweetAlert2允许文本输入,我给它一个默认值。我希望在弹出警报时突出显示此默认值,以便用户可以在需要时立即覆盖它。这是一个例子:
这是我使用 sweetAlert 选项调用的函数:
window.sweetPrompt = function (title, message, callback, input, keepopen, allowOutsideClick, allowEscapeKey) {
sweetAlert({
title: title,
text: message,
input: 'text',
confirmButtonColor: "#428bca",
preConfirm: function(text) {
return new Promise(function(resolve) {
if (!keepopen) {
resolve();
} else {
callback(text);
}
});
},
inputValidator: function(text) {
return new Promise(function (resolve, reject) {
if (text) {
resolve();
} else {
reject('Cannot be empty!');
}
});
},
inputValue: input,
showCancelButton: true,
reverseButtons: true,
allowOutsideClick: allowOutsideClick,
allowEscapeKey: allowEscapeKey
}).then(callback, function(dismiss){});
};
我该怎么做(如果可能的话)?我考虑过使用 jQuery,但不确定如何获取对 sweetAlert 对话框的引用。如有任何建议,我们将不胜感激。
最佳答案
给你:
Swal.fire({
input: 'text',
inputValue: 'input value',
didOpen: () => {
Swal.getInput().select()
}
})
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
附言。请注意,SweetAlert2 和 SweetAlert 是两个不同的项目,API 略有不同。
SweetAlert2 文档:https://sweetalert2.github.io/
关于javascript - 突出显示 sweetAlert 中的默认文本输入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44845663/
我可以将 inputType 设置为密码。支持哪些其他输入类型? swal({ title: "Are you sure?",
我正在链接到这个 SweetAlert 库 https://unpkg.com/sweetalert/dist/sweetalert.min.js,当我在移动设备上显示警报时,它显示得非常小。我增加了
这可能是 ServiceNow 问题,但我添加了一个 Sweet Alert 来显示一个选择框,这样我就可以收集一个值以传递给下一条记录......但选择框没有显示,弹出窗口只是没有框或选项。我错过了
在 sweet alert 2 中,如何在输入中加载设置值我的甜蜜警报代码 swal({ title: 'Are you sure?', tex
我想替换 javascript confirm with sweetalert,在下面的代码片段中,但是我发现了两个限制,1) sweetalert 不会像 confirm 那样暂停执行,2) swe
我想问一下如何用图片更改sweetalert中的icon图片? 我尝试用 assets 中的图像更改 Swal.fire 中的 icon 图像,但它不起作用 这是脚本 Swal.fire({
我正在使用 sweetAlert 进行对话框显示。在我的对话框中,我必须显示一个大字符串,中间有换行符。我的示例字符串如下: var str="Task1Name : Succ
我正在使用 Sweet Alert,当从 Sweet Alert 调用错误函数时,出现以下错误。当 php 文件的操作成功时,它就可以正常工作。如何解决这个问题呢?非常感谢 SweetAlert: M
我正在使用 SweetAlert,它在我的页面中使用此按钮运行良好: Title 但是我希望当有人进入页面时弹出该消息,而无需按按钮。 我必须做什么? 谢谢 最佳答案 window.onload
我知道以前有人问过这个问题,但我似乎找不到答案,我想询问 sweetalert 在 sweetalert 包含服务中的组件中不起作用用于删除数据。 组件 Swal({ title: 'Are
我正在使用 sweetalert 显示数据列表(大数据),然后允许用户从数据列表中进行选择。 sweetalert 的 HTML 是由后端生成的,但当我尝试打开此列表时,需要 10-15 秒的时间。
使用 SweetAlert 时,我在使用单引号时遇到问题,例如下面的代码有效 function test() { Swal.fire({ title: 'Are you sure?', te
您好,我正在使用 Sweet Alert 从我的网站中删除产品我想使用它有两个选项第一个是“确定”,第二个是“取消” 但是当我点击页面上的任何位置时,它会删除并且取消按钮不起作用 这是我的代码 $(
我有这个函数可以在用户按下删除然后再次按下确定后重置游戏。 function confirmReset() { swal({ title: "Are you sure yo
我目前正在使用 sweetalert2 从对话框中捕获用户的输入。我想在链接队列对话框中使用下拉菜单,但我似乎找不到在下拉列表中动态添加项目的方法。假设我想从 JSON 格式检索数据并将其放入下拉列表
我在 html 中使用以下代码 在该函数中,我检查错误并在发现错误时发出警报: function SveFrm(){ .... if (err > 0){ swal({ t
我正在使用 SweetAlert2,并且有一个选择列表。我的挑战是选择列表中的值是以编程方式添加的。当我的代码运行时,下拉列表具有正确的 NUMBER 个值,文本显示 [object Object]
我希望当用户尝试提交空表单时警报不会消失,相反它应该在同一警报中显示一些错误。我尝试执行 swal.showInputError("some error") 但它给出了一个错误它不是 有效的功能。我试
我正在使用 SweetAlert 的版本 1: https://github.com/errakeshpd/sweetalert-1 我的示例 ajax 代码如下,我保存用户数据的地方。 $.ajax
我正在使用 swal ( http://t4t5.github.io/sweetalert ) 在用户点击某些内容时从他们那里获取一些数据。然后我想从调用 swal 的函数中返回它。换句话说,对于下面
我是一名优秀的程序员,十分优秀!