How to remove all attributes of an HTML element using jQuery ? Last Updated : 17 May, 2023 Summarize Comments Improve Suggest changes Share Like Article Like Report In this article, we will see how to remove all attributes of an HTML element using jQuery. To remove all attributes of elements, we use the removeAttributeNode() method and .removeAllAttributes(). Syntax: $.fn.removeAllAttributes = function() { return this.each(function() { $.each(this.attributes, function() { this.ownerElement.removeAttributeNode(this); }); }); }; $('textarea').removeAllAttributes(); In the below example, we are creating a textarea element containing some attributes like - rows, cols, id, and name. When we apply the above code to a textarea element, all attributes will be removed. Example: In this example, we will remove textarea from all attributes using the above method. HTML <!DOCTYPE html> <html> <head> <title> How to remove all attributes of an HTML element using jQuery? </title> <script src= "https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"> </script> <style> #txtarea { font-size: 18px; background-color: green; } </style> <script> $(document).ready(function() { $("#position").on('click', function() { $.fn.removeAllAttributes = function() { return this.each(function() { $.each(this.attributes, function() { this.ownerElement.removeAttributeNode(this); }); }); }; $('textarea').removeAllAttributes(); }); }); </script> </head> <body> <center> <h1 style="color: green;"> GeeksforGeeks </h1> <h3> How to remove all attributes of an HTML element using jQuery? </h3> <input type="button" id="position" value="Remove All Attributes" style="padding: 5px 10px;"> <br><br> <textarea rows="7" cols="35" id="txtarea" name="comment">Welcome to GeeksforGeeks </textarea> </center> </body> </html> Output: Comment More infoAdvertise with us Next Article How to Add and Remove HTML Attributes with jQuery? V vkash8574 Follow Improve Article Tags : JQuery jQuery-Methods HTML-Questions jQuery-Questions Similar Reads How to Add Attributes to an HTML Element in jQuery? To add attributes to an HTML element in jQuery, the attr() method can be used. This allows to set one or more attributes for a selected element, such as id, class, src, and href.Approach: Given an HTML document containing <label>, <input>, and <button> elements. The <input> e 1 min read How to retrieve attribute of an HTML tag using jQuery ? In this article, we will learn how do you retrieve attributes of an HTML tag using jQuery. We can use JQuery to make this done in a few lines of code. Here we are going to build an image zooming system where will see how can an attribute of the HTML tag can be retrieved and changed. Using the attr() 2 min read How to Add and Remove HTML Attributes with jQuery? Using jQuery, we can dynamically add and remove HTML attributes such as placeholder, style, and more to enhance the interactivity and functionality of web elements based on user actions. We will explore two different approaches to adding and removing HTML attributes with jQuery. Below are the possib 2 min read How to remove contents of elements using jQuery ? In this article, we will discuss how to remove the contents of the elements using jQuery. To remove the contents of elements, we will use the empty() method and the remove() method. The jQuery empty() method is used to remove all child nodes and their content for the selected elements. This method d 3 min read How to remove an attribute from each matched elements using jQuery ? In this article, we will learn how to remove an attribute from each of the matched elements using JQuery. JQuery is the fastest and lightweight JavaScript library that is used to simplify the interactions between an HTML/CSS document, or more precisely the Document Object Model (DOM), and JavaScript 2 min read How to add and remove CSS classes to an element using jQuery ? In this article, we will see how to add or remove the CSS classes to an element using jQuery. To add the CSS classes to an element we use addClass() method, and to remove the CSS classes we use removeClass() method. Syntax: The syntax for adding CSS classes to an element: $('selector').addClass(clas 2 min read Like