How to Remove all Inline Styles using JavaScript/jQuery? Last Updated : 14 Oct, 2024 Summarize Comments Improve Suggest changes Share Like Article Like Report To remove all inline styles from an element using JavaScript or jQuery, the removeAttribute method in JavaScript or the removeAttr method in jQuery can be used. Approach: The jQuery attr() and removeAttr() methods are used to remove the inline style property. The attr() method sets the attribute value to empty (''). Example 1: This example uses attr() method to remove the inline style. HTML <!DOCTYPE HTML> <html> <head> <title> How to remove all inline styles using JavaScript/jQuery ? </title> <script src= "https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"> </script> <style> .parent { background: green; } .child1 { background: blue; margin: 10px; } .child2 { background: red; margin: 10px; } </style> </head> <body style="text-align:center;"> <p id="GFG_UP" style="font-size: 15px; font-weight: bold;"> </p> <div class="parent" id="parent" style="color:white"> Parent <div class="child child1"> Child1 </div> <div class="child child2"> Child2 </div> </div> <br> <button onclick="GFG_Fun()"> click here </button> <p id="GFG_DOWN" style="font-size: 24px; font-weight: bold; color: green;"> </p> <script> let up = document.getElementById('GFG_UP'); let down = document.getElementById('GFG_DOWN'); let parent = document.getElementById('parent'); up.innerHTML = "Click on the button to remove" + " the inline style."; function GFG_Fun() { $('#parent').attr('style', ''); down.innerHTML = "Inline style has been removed."; } </script> </body> </html> Output: Example 2: The jQuery removeAttr() method is used to remove the inline style property. The removeAttr() method removes the value of style attribute. HTML <!DOCTYPE HTML> <html> <head> <title> How to remove all inline styles using JavaScript/jQuery ? </title> <script src= "https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"> </script> <style> .parent { background: green; } .child1 { background: blue; margin: 10px; } .child2 { background: red; margin: 10px; } </style> </head> <body style="text-align:center;"> <p id="GFG_UP" style= "font-size: 15px; font-weight: bold;"> </p> <div class="parent" id="parent" style="color:white"> Parent <div class="child child1"> Child1 </div> <div class="child child2"> Child2 </div> </div> <br> <button onclick="GFG_Fun()"> click here </button> <p id="GFG_DOWN" style= "font-size: 24px; font-weight: bold; color: green;"> </p> <script> let up = document.getElementById('GFG_UP'); let down = document.getElementById('GFG_DOWN'); let parent = document.getElementById('parent'); up.innerHTML = "Click on the button to remove " + "the inline style."; function GFG_Fun() { $('#parent').removeAttr('style'); down.innerHTML = "Inline style has been removed."; } </script> </body> </html> Output: Comment More infoAdvertise with us Next Article How to Remove all Inline Styles using JavaScript/jQuery? P PranchalKatiyar Follow Improve Article Tags : JavaScript Web Technologies jQuery-Misc Similar Reads How to remove CSS style of <style> tag using JavaScript/jQuery ? Given an HTML document containing inline and internal CSS and the task is to remove the style of <style> tag. The internal or embedded CSS is used within the head section of the HTML document. It is enclosed within <style> tag. Approach: The jQuery remove() and empty() methods are used t 2 min read How to disable HTML links using JavaScript / jQuery ? Given an HTML link and the task is to disable the link by using JavaScript/jQuery. Approach 1: Disable HTML link using JavaScript using setAttribute() Method. JavaScript setAttribute() Method: This method adds the defined attribute to an element and gives it to the passed value. In case of the speci 5 min read How to remove CSS property using JavaScript? To remove CSS property using JavaScript, we have different methods. In this article, we will learn how to remove CSS property using JavaScript. Below are the Methods used to remove CSS property using JavaScript: Table of Content Using CSS removePropertyUsing the setProperty methodMethod 1: Using CSS 2 min read How to remove HTML tags from a string using JavaScript ? Removing HTML tags from a string in JavaScript means stripping out the markup elements, leaving only the plain text content. This is typically done to sanitize user input or to extract readable text from HTML code, ensuring no unwanted tags remain in the string.HTML tags come in two forms: opening t 3 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 Like