Javascript 我如何申请;ID";对于sweetAlert.js?
我正在尝试将id应用于sweet alert select元素。我只知道如何添加类,但我试图在off.docs中找到如何添加ID。但是找不到。感谢您的帮助。目前无法直接向Sweetalert模式添加Id 但是,我们可以通过以下方式将类添加到Sweetalert模式:Javascript 我如何申请;ID";对于sweetAlert.js?,javascript,html,css,sweetalert,sweetalert2,Javascript,Html,Css,Sweetalert,Sweetalert2,我正在尝试将id应用于sweet alert select元素。我只知道如何添加类,但我试图在off.docs中找到如何添加ID。但是找不到。感谢您的帮助。目前无法直接向Sweetalert模式添加Id 但是,我们可以通过以下方式将类添加到Sweetalert模式: customClass:“类名”, 通过添加onOpen函数,还可以为Sweetalert中的不同元素添加Id: onOpen:function(){$('.swal2-modal').attr('id','modal_-id');
customClass:“类名”,
通过添加onOpen函数,还可以为Sweetalert中的不同元素添加Id:
onOpen:function(){$('.swal2-modal').attr('id','modal_-id');$('.swal2-content').attr('id','modalcontent_-id');}
目前无法直接向Sweetalert-modal添加id
但是,我们可以通过以下方式将类添加到Sweetalert模式:
customClass:“类名”,
通过添加onOpen函数,还可以为Sweetalert中的不同元素添加Id:
onOpen:function(){$('.swal2 modal').attr('id','modal_id');$('.swal2 content').attr('id','modalcontent_id'))}
您可以在sweetalert2
中实现它,我希望能对您有所帮助
// # in this example result -> id="txt-note"
Swal.fire({
title: "Ingrese el contenido de la nota",
input: "text",
inputAttributes: {
id: "txt-note",
},
customClass: {
container: "modal-create-note",
},
showCancelButton: true,
confirmButtonText: "Crear",
showLoaderOnConfirm: true,
preConfirm: (textoNota) => {
console.log(textoNota)
},
allowOutsideClick: () => !Swal.isLoading(),
}).then((result) => {
console.log(result);
});
Swal.fire({
标题:“安格尔·艾尔·孔泰多·德拉诺塔”,
输入:“文本”,
输入属性:{
id:“txt注释”,
},
客户类别:{
容器:“模态创建注释”,
},
showCancelButton:true,
confirmButtonText:“Crear”,
请确认:正确,
预确认:(textoNota)=>{
console.log(textoNota)
},
allowOutsideClick:()=>!Swal.isLoading(),
})。然后((结果)=>{
控制台日志(结果);
});代码>
你能做到,在sweetalert2
中,我希望能对你有所帮助
// # in this example result -> id="txt-note"
Swal.fire({
title: "Ingrese el contenido de la nota",
input: "text",
inputAttributes: {
id: "txt-note",
},
customClass: {
container: "modal-create-note",
},
showCancelButton: true,
confirmButtonText: "Crear",
showLoaderOnConfirm: true,
preConfirm: (textoNota) => {
console.log(textoNota)
},
allowOutsideClick: () => !Swal.isLoading(),
}).then((result) => {
console.log(result);
});
Swal.fire({
标题:“安格尔·艾尔·孔泰多·德拉诺塔”,
输入:“文本”,
输入属性:{
id:“txt注释”,
},
客户类别:{
容器:“模态创建注释”,
},
showCancelButton:true,
confirmButtonText:“Crear”,
请确认:正确,
预确认:(textoNota)=>{
console.log(textoNota)
},
allowOutsideClick:()=>!Swal.isLoading(),
})。然后((结果)=>{
控制台日志(结果);
});代码>
您是在谈论customClass
属性,并且您想要类似的东西,只是ID?如果是这样的话-你为什么需要它?是的,ID。我需要初始化其他需要ID的插件。这是你的意思吗?是的,就是这样:)非常感谢您谈论的customClass
属性,您想要类似的东西,只有ID?如果是这样的话-你为什么需要它?是的,ID。我需要初始化其他需要ID的插件。这是你的意思吗?是的,就是这样:)非常感谢