Bootstrap Tutorial - Remove a table row








The following code shows how to remove a table row.

Example

<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'
  src='http://code.jquery.com/jquery-1.10.1.js'></script>
<link rel="stylesheet" type="text/css"
  href="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css"
  href="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap-theme.min.css">
<script type='text/javascript'
  src="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>
<link rel="stylesheet" type="text/css"
  href="http://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css">
<script type='text/javascript'>
$(window).load(function(){<!--from   w  w  w.  ja v a 2s.  c  om-->
$(function () {
    $("table#bootstrap_git_demo").on("click", ".remove", function () {
        $(this).closest('tr').remove();
    });
});
$(function () {
    $(".show_tip").tooltip({
        container: 'body'
    });
});
$(document).click(function () {
    $('.tooltip').remove();
    $('[title]').tooltip();
});
});
</script>
</head>
<body style='margin:30px'>
  <table class="table table-striped table-bordered"
    id="bootstrap_git_demo">
    <thead>
      <tr>
        <th>Name</th>
        <th>Id</th>
        <th>Location</th>
        <th>Status</th>
        <th>Edit</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td>Element Alfa</td>
        <td>Selector A</td>
        <td>Area A</td>
        <td>Inactive</td>
        <td>
          <button title="" type="button"
            class="btn btn-danger remove show_tip"
            data-original-title="Remove from list">
            <i class="fa fa-trash-o"></i>
          </button>
        </td>
      </tr>
    </tbody>
  </table>
</body>
</html>

Click to view the demo