原文地址: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 }; //邏輯處理 });