我正在尝试确定在点击以下代码中的“删除”按钮时如何触发事件。
<div aria-labelledby="myModalLabel" class="modal fade" id="removeUser"
role="dialog" tabindex="-1">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-body" id="window-border">
<div class="warning-text">
<h2>Remove User</h2>
<p>Are you sure you wish to remove this user?</p>
</div>
<div class="terminate">
<button class="btn btn-default close" data-dismiss=
"modal" type="button">Cancel</button>
<button class=
"btn btn-default" id="confirm" type=
"submit">Remove</button>
</div>
</div>
</div><!-- end modal content -->
</div>
</div>
答案 0 :(得分:1)
你可以点击jquery文件点击一个点击功能,如下所示:
$( document ).on( "click", "#confirm", function() {
//your code here
});
答案 1 :(得分:0)
//Indicate user the avaliable time period
$('#confirm').click( function() {
alert("removed");
});
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div aria-labelledby="myModalLabel" class="modal fade" id="removeUser"
role="dialog" tabindex="-1">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-body" id="window-border">
<div class="warning-text">
<h2>Remove User</h2>
<p>Are you sure you wish to remove this user?</p>
</div>
<div class="terminate">
<button class="btn btn-default close" data-dismiss=
"modal" type="button">Cancel</button>
<button class=
"btn btn-default" id="confirm" type=
"submit">Remove</button>
</div>
</div>
</div><!-- end modal content -->
</div>
</div>
&#13;