甜蜜警报2,自定义按钮



我在sweet alert中添加了两个自定义按钮,但它们的功能不起作用,你能建议我修复吗?

//Custom buttons
html: '<button id="prev-btn" class="btn btn-warning"><i class="fas fa-angle-left fa-3x"></i></button>' +
'<button id="next-btn" class="btn btn-primary"><i class="fas fa-angle-right fa-3x"></i></button>',
//Functions for them
$("#next-btn").on("click", function() {
if(currentMarineKnotIndex+1 == receivedArray.length){
currentMarineKnotIndex = 0;
}
else{
currentMarineKnotIndex++;
}
$(".nautical-knot-title").html(receivedArray[currentMarineKnotIndex].nameLV+"<br>");
$(".nautical-knot-desc").html(receivedArray[currentMarineKnotIndex].descriptionLV);
$("#modal-header-div").css("background", "url('../Images/uploads/"+receivedArray[currentMarineKnotIndex].Image+"')");
});
$("#prev-btn").on("click", function() {
if(currentMarineKnotIndex == 0){
currentMarineKnotIndex = receivedArray.length - 1;
}else{
currentMarineKnotIndex--;
}
$(".nautical-knot-title").html(receivedArray[currentMarineKnotIndex].nameLV+"<br>");
$(".nautical-knot-desc").html(receivedArray[currentMarineKnotIndex].descriptionLV);
$("#modal-header-div").css("background", "url('../Images/uploads/"+receivedArray[currentMarineKnotIndex].Image+"')");

这个链接(官方网站(可能很有用->https://sweetalert.js.org/guides/

最新更新