First you have to download the jQuery plugin.
Here is the link for the jQuery that i used in this tutorial https://jquery.com/.
Lastly, this is the link for the template that i used for the layout design https://getbootstrap.com/.
<html lang="eng"> <head> <meta charset="UTF-8"/> <link rel="stylesheet" type="text/css" href="css/bootstrap.css" /> </head> <body> <nav class="navbar navbar-default"> <div class="container-fluid"> </div> </nav> <div class="container-fluid"> <div class="row"> <div class="col-md-6 well"> <hr style="border-top: 1px SOLID #8c8b8b;"/> <ul> </ul> </div> </div> </div> </body> </html>
<script src = "js/jquery-3.2.1.min.js"></script> <script> $(document).ready(function(){ $(".remove").click(function(){ $(this).closest('li').fadeOut(); }); }); </script>
In this code we bind the button class element into the click function in order to trigger some event. After we bind the button we targeted the closest parent element of the button. Then we use fadeOut() function to remove the entire HTML list element along with the button.
The How to Remove an Element with jQuery source code that I provide can be download below. Please kindly click the download button.
There you have it we successfully created How to Remove an Element with jQuery. I hope that this simple tutorial help you to what you are looking for. For more updates and tutorials just kindly visit this site. Enjoy Coding!
More Tutorials for JavaScript Language