Bootstrap: 弹出窗口Modal不消失, 点击外部不关闭窗口Modal, How to prevent Bootstrap modal from closing when clicking outside




<!DOCTYPE html>
<html lang="en">
<meta charset="UTF-8">
<title>Disallow Bootstrap Modal from Closing</title>
<link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="stylesheet" href="css/bootstrap-theme.min.css">
<script src=""></script>
<script src="js/bootstrap.min.js"></script>
<script type="text/javascript">
            backdrop: 'static',
            keyboard: false
    <!-- Button HTML (to Trigger Modal) -->
    <input type="button" class="btn btn-lg btn-primary show-modal" value="Show Demo Modal">
    <!-- Modal HTML -->
    <div id="myModal" class="modal fade">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <h4 class="modal-title">Confirmation</h4>
                <div class="modal-body">
                    <p>Do you want to save changes you made to document before closing?</p>
                    <p class="text-warning"><small>If you don't save, your changes will be lost.</small></p>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                    <button type="button" class="btn btn-primary">Save changes</button>



本文: Bootstrap: 弹出窗口不消失, 点击外部不关闭窗口, How to prevent Bootstrap modal from closing when clicking outside


Add a Comment

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.