Jquery

Jquery Remove Parent Table Row on Button Click Event

Pinterest LinkedIn Tumblr
<!DOCTYPE html>
<html>
<head>
    <title>Jquery Remove Parent Table Row on Button Click Event: Real Programmer</title>
    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
</head>
<body>
   
<table>
    <tr>
        <th>ID</th>
        <th>Name</th>
        <th>Email</th>
        <th>Action</th>
    </tr>
    <tr>
        <td>1</td>
        <td>Siddharth</td>
        <td>[email protected]</td>
        <td><button class="btn-remove">Remove</button></td>
    </tr>
    <tr>
        <td>2</td>
        <td>Yash</td>
        <td>[email protected]</td>
        <td><button class="btn-remove">Remove</button></td>
    </tr>
    <tr>
        <td>3</td>
        <td>Chotu</td>
        <td>[email protected]</td>
        <td><button class="btn-remove">Remove</button></td>
    </tr>
</table>
    
<script type="text/javascript">
   
    $(document).ready(function () {
   
        $("body").on("click", ".btn-remove", function(){
            $(this).closest('tr').remove();
        });
   
    });
   
</script>
   
</body>
</html>

Write A Comment

Open chat
Hey Visitor,

How can I help you?