原文地址:https://www.cnblogs.com/HwChinchilla/p/8942092.html
$(".demo_5 button").click(function() { swal({ title: "Good!", text: '自定义<span style="color:red">图片</span>、<a href="#">HTML内容</a>。<br/>5秒后自动关闭。', imageUrl: "images/thumbs-up.jpg", html: true, timer: 5000, showConfirmButton: false }); });
实战
var html = $(obj).parent(".amount-warp").find(".divAdjustNum").html(); swal({ title: "调整XX数量", text: html, html: true, showCancelButton: true, closeOnConfirm: false, animation: "slide-from-top", inputPlaceholder: "输入调整后的数量", cancelButtonText: "取消", confirmButtonText: "确认", }, function (inputValue) { var newNum = $(".sweet-alert #goods_number_" + rec_id).val(); var errorDiv = $(".sweet-alert .divAdjustNumError")[0]; if (!newNum) { errorDiv.innerText="数量无效!"; return false } if (curnum == newNum) { errorDiv.innerText="数量未改变!"; return false }; //逻辑处理 });