Ans:  To remove element from webpage/dom use remove() jquery method.

Following example shows you how to remove element.

<!--
Used basic html and bootstrap skeleton from the below link for style purpose which contains bootstrap.css,bootstrap.js,jquery.js
https://www.w3schools.com/bootstrap/bootstrap_get_started.asp
-->
<!DOCTYPE html>
<html lang="en">
    <head>
        <title>How to remove elements from Webpage/DOM in jQuery</title>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">        
    </head>
    <body>
        <div class="container" style="max-width:800px;margin:0 auto;margin-top:50px;">  
            <div>
                <h2 style="margin-bottom:50px;">How to remove elements from Webpage/DOM in jQuery</h2>              
            </div>
            <div>
                <button type="button" class="remove-image btn btn-success">Remove Image</button>   
            </div>
            <div>
                <img class="meme-image" src="https://www.photogur.com/post_images/49c25f029e3326bd08431b654a756c4b.jpg"/>
            </div>
        </div>
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
        <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
        <script>
            $(document).ready(function () {
                $(".remove-image").click(function () {
                    $(".meme-image").remove();
                });
            });
        </script>
    </body>
</html>


On clicking remove image button it will remove the image tag from the page. Sometime in your project you need to remove the text input, images, or even div
 use remove() method to remove it.  

Written by
Check out this Author's contributed articles.
If you like Tutorialsmint and would like to contribute, you can also write an article using Write an Article. See your article appearing on the Tutorialsmint main page and help other programmers to enhance their knowledge.

Comments(0)

RECENT TUTORIALS
Wed Dec 26 • 08:00 AM GMT
Wed Dec 26 • 08:00 AM GMT
Wed Dec 26 • 08:00 AM GMT
Wed Dec 26 • 08:00 AM GMT
Wed Dec 26 • 08:00 AM GMT
Edit Post
Add Reply