Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/382.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何仅在按下取消按钮时关闭模式弹出窗口?_Javascript_Jquery_Html_Css - Fatal编程技术网

Javascript 如何仅在按下取消按钮时关闭模式弹出窗口?

Javascript 如何仅在按下取消按钮时关闭模式弹出窗口?,javascript,jquery,html,css,Javascript,Jquery,Html,Css,我有一个简单的模式,我想知道我怎么能只允许关闭模式时,点击“X”按钮或取消按钮。现在,当用户在模式区域外单击时。 这是我的密码: <div class="container"> <h2>Modal Example</h2> <!-- Trigger the modal with a button --> <button type="button" class="btn btn-info btn-lg" data-toggle="

我有一个简单的模式,我想知道我怎么能只允许关闭模式时,点击“X”按钮或取消按钮。现在,当用户在模式区域外单击时。 这是我的密码:

 <div class="container">
  <h2>Modal Example</h2>
  <!-- Trigger the modal with a button -->
  <button type="button" class="btn btn-info btn-lg" data-toggle="modal" data-target="#myModal">Open Modal</button>

  <!-- Modal -->
  <div class="modal fade" id="myModal" role="dialog">
    <div class="modal-dialog">

      <!-- Modal content-->
      <div class="modal-content">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal">&times;</button>
          <h4 class="modal-title">Modal Header</h4>
        </div>
        <div class="modal-body">
          <p>Some text in the modal.</p>
        </div>
        <div class="modal-footer">
          <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
        </div>
      </div>

    </div>
  </div>

</div>

模态示例
开放模态
&时代;
模态头
模态中的一些文本

接近
使用此

$('#myModal').modal({
    backdrop: 'static',
    keyboard: false
})
或者直接放在你的沙发上

<div id="myModal" class="modal hide" data-backdrop="static" data-keyboard="false">

使用此

$('#myModal').modal({
    backdrop: 'static',
    keyboard: false
})
或者直接放在你的沙发上

<div id="myModal" class="modal hide" data-backdrop="static" data-keyboard="false">