【轉】在sweetalert中 加入html代碼


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

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM