Delete Button Modal Popup

by TheOrdinaryGeek

HTML

<script src="//netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css">
<table>
  <thead>
    <tr>
      <th>Content 1</th>

      <th>Content 2</th>
      <th>Status</th>
      <th>Edit / View / Delete</th>
    </tr>
  </thead>
  <!-- start: Table Body -->
  <tbody>
    <tr class="btnDelete" data-id="1">
      <td>Content1</td>

      <td>Content2</td>
      <td>Active</td>
      <td>
        <button class="btnDelete" href="">delete</button>
      </td>
    </tr>
    <tr class="btnDelete" data-id="2">
      <td>Content3</td>
      <td>Content4</td>
      <td>Active</td>
      <td>
        <button class="btnDelete" href="">delete</button>
      </td>
    </tr>
  </tbody>
</table>
<!--/table-collapse -->
<!-- start: Delete Coupon Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <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>
        <h3 class="modal-title" id="myModalLabel">Warning!</h3>

      </div>
      <div class="modal-body">
        <h4> Are you sure you want to DELETE?</h4>

      </div>
      <!--/modal-body-collapse -->
      <div class="modal-footer">
        <button type="button" class="btn btn-danger" id="btnDelteYes" href="#">Yes</button>
        <button type="button" class="btn btn-default" data-dismiss="modal">No</button>
      </div>
      <!--/modal-footer-collapse -->
    </div>
    <!-- /.modal-content -->
  </div>
  <!-- /.modal-dialog -->
</div>
<!-- /.modal -->

JavaScript

$('button.btnDelete').on('click', function(e) {
  e.preventDefault();
  var id = $(this).closest('tr').data('id');
  $('#myModal').data('id', id).modal('show');
});

$('#btnDelteYes').click(function() {
  var id = $('#myModal').data('id');
  $('[data-id=' + id + ']').remove();
  $('#myModal').modal('hide');
});