zoukankan      html  css  js  c++  java
  • bootstrap 操作提示placeholder

    Javascript 部分

    function checkForDefaultAlertPlaceholder() {
        if ($("#alertPlaceholder").length == 0) {
            $("body > div:nth-child(2)").prepend($('<div id="alertPlaceholder"></div>'));
        }
    }
    bootstrap_alert = function () { }
    bootstrap_alert.danger = function (message, timeout, idContainer) {
        if (idContainer == null) {
            checkForDefaultAlertPlaceholder();
        }
        var $alert = $('<div class="alert alert-danger alert-dismissable fade in" role="alertdialog"><strong>Error:</strong> ' + message + '<button type="button" class="close" data-dismiss="alert" aria-hidden="true"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button></div>');
        $("#" + (idContainer != null ? idContainer : "alertPlaceholder")).append($alert);
        if (timeout != null && timeout > 0) {
            setTimeout(function () {
                $alert.alert("close");
            }, timeout);
        }
        return $alert;
    }
    bootstrap_alert.warning = function (message, timeout, idContainer) {
        if (idContainer == null) {
            checkForDefaultAlertPlaceholder();
        }
        var $alert = $('<div class="alert alert-warning alert-dismissable fade in" role="alertdialog">' + message + '<button type="button" class="close" data-dismiss="alert" aria-hidden="true"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button></div>');
        $("#" + (idContainer != null ? idContainer : "alertPlaceholder")).append($alert);
        if (timeout != null && timeout > 0) {
            setTimeout(function () {
                $alert.alert("close");
            }, timeout);
        }
        return $alert;
    }
    bootstrap_alert.success = function (message, timeout, idContainer) {
        if (idContainer == null) {
            checkForDefaultAlertPlaceholder();
        }
        var $alert = $('<div class="alert alert-success alert-dismissable fade in" role="alertdialog"><strong>Success:</strong> ' + message + '<button type="button" class="close" data-dismiss="alert" aria-hidden="true"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button></div>');
        $("#" + (idContainer != null ? idContainer : "alertPlaceholder")).append($alert);
        if (timeout != null && timeout > 0) {
            setTimeout(function () {
                $alert.alert("close");
            }, timeout);
        }
        return $alert;
    }

    将DIV加在表头某处:

    <div id="alertPlaceholder"></div>

    Ajax调用代码区:

     $('#').click(function(){
             $.ajax({
                type:'POST',
                url:<link>,
                data:{},
                success:function(data){
                 bootstrap_alert.success("The data has been saved.", 1000);
            },
                error:function(data){
                bootstrap_alert.danger("Exception!This operation is not performed successfully! Please contact admin!", 1000);
                }
            });
    
            });
  • 相关阅读:
    thinkphp验证码功能
    thinkphp表单验证
    thinkphp操作数据库的CRUD
    thinkphp基础知识
    什么是预测区间,置信区间与预测区间二者的异同是什么?
    好消息! 不用再羡慕Python有jupyter 我R也有Notebook了【附演示视频】
    手把手教你在Windows环境下升级R
    Feather包实现数据框快速读写,你值得拥有
    pycharm设置字体大小
    pycharm显示行号
  • 原文地址:https://www.cnblogs.com/kiddy/p/9838523.html
Copyright © 2011-2022 走看看