$(this) Selector in jQuery
We can select current element using $(this) selector in jQuery.The following example shows, how to remove a selected table row using $(this) selector in jQuery.
Example
<html> <head> <title>Selectors in jQuery</title> <script src="https://code.jquery.com/jquery-2.2.4.min.js"></script> <style> table{ width:50%; margin:50px auto; border-collapse:collapse; } td,th{ border:1px solid #ccc; padding:10px; } </style> </head> <body> <table> <thead> <tr> <th>SNo</th> <th>Name</th> <th>Email</th> <th>Action</th> </tr> </thead> <tbody> <tr> <td>1</td> <td>Nielsen</td> <td>nielsen@test.com</td> <td><input type='button' class='btn' value='Remove'></td> </tr> <tr> <td>2</td> <td>Tom</td> <td>tom@test.com</td> <td><input type='button' class='btn' value='Remove'></td> </tr> <tr> <td>3</td> <td>Sam</td> <td>sam@test.com</td> <td><input type='button' class='btn' value='Remove'></td> </tr> <tr> <td>4</td> <td>Jhon Smith</td> <td>jhon smith@test.com</td> <td><input type='button' class='btn' value='Remove'></td> </tr> <tr> <td>5</td> <td> Edwards</td> <td>edwards@test.com</td> <td><input type='button' class='btn' value='Remove'></td> </tr> </tbody> </table> <script> $("document").ready(function(){ $(".btn").click(function(){ $(this).parents("tr").remove(); }); }); </script> </body> </html>Try it Yourself