Reputation: 1218
I'm trying to determine how to trigger an event when the Remove button in the below code is clicked.
<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>
Upvotes: 0
Views: 3886
Reputation: 133
//Indicate user the avaliable time period
$('#confirm').click( function() {
alert("removed");
});
<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>
Upvotes: 0
Reputation: 9055
you can delegate a click function with jquery document on click like so:
$( document ).on( "click", "#confirm", function() {
//your code here
});
Upvotes: 1