单击时,Bootstrap Modal不会弹出警报

时间:2018-11-11 00:51:56

标签: javascript jquery html modal-dialog

Bootstrap Modal按钮保存在单击时不起作用。下面是我的jQuery:

$('#add-more-academic').on('click',function(){
        $('#myModal').modal();
    })
    //==================================================
    $('.SaveAcademic').on('click',function(){
        var academic = $('#new-academic').val();
        alert(academic);

在我的模式上单击“保存”后,将显示一个警告对话框,显示我在文本框中输入的内容。下面是我的模态:

<!-- Modal -->
<div id="myModal" tabindex="-1" aria-hidden="true" class="modal fade" 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">Academic Year</h4>
      </div>
      <div class="modal-body">
        <div class="row">
            <div class="col-sm-12">
                <input type="text" name="academic_year" id="new-academic" class="form-control" placeholder="Academic Year">
            </div>
        </div>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
        <button type="button" class="btn btn-success SaveAcademic" id="SaveAcademic">Save</button>
      </div>
    </div>

  </div>
</div>
</html>

1 个答案:

答案 0 :(得分:0)

选中此link,以获取有关引导程序和警报的更多信息。