基於bootstrap的模態框的comfirm彈窗

來源:互聯網
上載者:User

標籤:dial   button   ack   js代碼   function   bsp   dismiss   first   bin   

完成的效果如下:

html代碼如下:

        <button id="btn">點擊彈出彈框</button>        <!-- 彈出框 -->        <div class="modal fade" id="confirm_like" tabindex="-1">            <!-- 視窗聲明 -->            <div class="modal-dialog modal-sm">                <!-- 內容聲明 -->                <div class="modal-content">                    <div class="modal-header" style="padding-top: 10px; padding-bottom: 10px;">                        <button class="close" data-dismiss="modal">                            <span>&times;</span>                        </button>                        <h4 class="modal-title" id="myModalLabel"></h4>                    </div>                    <div class="modal-body">                        <div id="modal_con" style="text-align: center;"></div>                        <div id="firstDiv"></div>                    </div>                    <div class="modal-footer" style="text-align: center; padding-top: 10px; padding-bottom: 10px;margin-top:0;">                        <button class="btn btn-sm btn-success" data-dismiss="modal" id="ok_btn">確 定</button>                        <button class="btn btn-sm btn-success" data-dismiss="modal" id="cancel_btn">取 消</button>                    </div>                </div>            </div>        </div>

js代碼如下:

    $("#btn").click(function(){        //調用        show_confirm(‘提示‘, ‘資料提交中‘,certain,cancel);    });    //顯示彈窗函數    function show_confirm(title, msg ,ok_callback,cancel_callback) {        $("#isConfirm").val(‘false‘);        $("#myModalLabel").text(title);//這裡設定彈窗的標題        $("#modal_con").text(msg);//設定提示的資訊        $("#confirm_like").modal({//顯示彈窗            show : true,            //backdrop : true,去掉遮罩層        });        //確定按鈕事件函數        $("#ok_btn").click(function(){            if($.isFunction(ok_callback)){                $(‘#confirm_like‘).off(‘hidden.bs.modal‘);        //解除綁定事件,防止多次綁定                $(‘#confirm_like‘).on(‘hidden.bs.modal‘, function(){ok_callback("這是確定");});                    }        });        //取消按鈕事件函數        $("#cancel_btn").click(function(){            if($.isFunction(cancel_callback)){                $(‘#confirm_like‘).off(‘hidden.bs.modal‘);                $(‘#confirm_like‘).on(‘hidden.bs.modal‘, function(){cancel_callback();});                    }        });        //彈窗的關閉按鈕事件函數        $("#confirm_like .close").click(function(){            if($.isFunction(cancel_callback)){                $(‘#confirm_like‘).off(‘hidden.bs.modal‘);                $(‘#confirm_like‘).on(‘hidden.bs.modal‘, function(){cancel_callback();});                    }                    });    }    function certain(str){        alert(str);    }    function cancel(){        alert("這是取消");    }

 

基於bootstrap的模態框的comfirm彈窗

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.