weui 弹出层

function dialog(title, msg, callback) {
        dialog2 = '\
        <div class="weui_dialog_alert" id="dialog2" style="display: none;">\
            <div class="weui_mask"></div>\
           <div class="weui_dialog">\
            <div class="weui_dialog_hd"><strong class="weui_dialog_title">' + title + '</strong></div>\
            <div class="weui_dialog_bd">' + msg + '</div>\
            <div class="weui_dialog_ft">\
             <a href="javascript:;" class="weui_btn_dialog primary">确定</a>\
            </div>\
           </div>\
          </div>\
         ';
        if (!$('#dialog2').length) {
            $('body').append(dialog2);
        } else {
            $('#dialog2 .weui_dialog_title').html(title);
            $('#dialog2 .weui_dialog_bd').html(msg);
        }
        $('#dialog2').fadeIn('fast');
        $('#dialog2 .primary').on('click', function () {
            $('#dialog2').fadeOut('fast');
            var url = callback;
            if (url !== '') {
                window.location.href = url;
            }
        });

    }

  

posted @ 2018-07-03 18:33  网络一闲人  阅读(11029)  评论(0编辑  收藏  举报