How to Remove HTML element from DOM using AngularJS ? Last Updated : 08 Nov, 2022 Suggest changes Share Like Article Like Report In this article, we will see how to remove particular HTML elements from the DOM with the help of AngularJS, along with understanding its implementation through the examples. For this, we can use the remove() method that helps to remove all the selected elements including all the text. Syntax: selectObject.remove();Approach: Here first we select the element that we want to remove. Then we use the remove() method to remove that particular element. Example 1: This example describes removing the HTML element from DOM in AngularJS. Here the element of class('p') has been removed. HTML <!DOCTYPE HTML> <html> <head> <title>Remove a HTML element from DOM</title> <script src= "//ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular.min.js"> </script> <style> body { text-align: center; font-family: 'Times New Roman', Times, serif; } h1 { color: green; } .p { border: 1px solid black; } </style> <script> var myApp = angular.module("app", []); myApp.controller("controller", function ($scope) { $scope.removeEl = function () { var el = angular.element( document.querySelector('.p')); el.remove(); }; }); </script> </head> <body> <h1>GeeksforGeeks</h1> <h3>Remove a HTML element from DOM</h3> <div ng-app="app"> <div ng-controller="controller"> <p class="p">This is paragraph</p> <input type="button" value="Click here" ng-click="removeEl()"> </div> </div> </body> </html> Output: Example 2: This example describes removing the HTML element from DOM in AngularJS. Here the element of Id('p') has been removed by the remove() method. HTML <!DOCTYPE HTML> <html> <head> <title> Remove a HTML element from DOM </title> <script src= "//ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular.min.js"> </script> <script> var myApp = angular.module("app", []); myApp.controller("controller", function($scope) { $scope.removeEl = function() { var el = angular.element(document.querySelector('#div')); el.remove(); }; }); </script> <style> body { text-align: center; font-family: 'Times New Roman', Times, serif; } h1 { color: green; } #div { height: 50px; width: 100px; margin: 0 auto; background: green; color: white; } </style> </head> <body> <h1>GeeksforGeeks</h1> <h3>Remove a HTML element from DOM</h3> <div ng-app="app"> <div ng-controller="controller"> <div id="div">Element</div> <br> <input type="button" value="Click here" ng-click="removeEl()"> </div> </div> </body> </html> Output: Advertise with us Next Article How to Remove HTML element from DOM using AngularJS ? P PranchalKatiyar Follow Similar Reads How to Delete a Row from Table using AngularJS ? Given a HTML table and the task is to remove/delete the row from the table with the help of AngularJS.Approach: The approach is to delete the row from the array where it stored and served to the table data. When the user clicks on the button near to the table row, it passes the index of that table a 2 min read How to remove an HTML element using JavaScript ? Removing an HTML element using JavaScript involves deleting it from the DOM, typically using methods like element.remove() or parentNode.removeChild(). This approach updates the webpage dynamically, allowing for responsive interactions by removing unwanted or outdated elements based on user actions 3 min read How to empty the content of an element using AngularJS ? In this article, we will see how to remove the content of an element in HTML DOM using AngularJS. This task can be accomplished by implementing the jQuery empty() method that removes all child nodes and their content for the selected elements. Syntax: element.empty();Parameter: This method does not 2 min read How to delete text from document using HTML ? In this article, we delete text from an HTML document by using the <del> tag in the document. This tag stands for delete and is used to mark a portion of text which has been deleted from the document. Syntax: <del> Contents... </del> Example: In the following example, deletion of a 1 min read Remove duplicate elements from an array using AngularJS We have given an array and the task is to remove/delete the duplicates from the array using AngularJS.Approach: The approach is to use the filter() method and inside the method, the elements that don't repeat themselves will be returned and the duplicates will be returned only once.Hence, a unique a 2 min read Article Tags : Web Technologies AngularJS AngularJS-Questions Like