How to Remove all Inline Styles using JavaScript/jQuery? Last Updated : 14 Oct, 2024 Comments Improve Suggest changes 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 How to Remove and add Style with .css() Function using JavaScript? There are many cases, especially as the content gets more interactive, where the developer wants styles to dynamically kick in based on user input, some code having run in the background, and more. In these sorts of scenarios, the CSS model involving style rules or inline styles doesn't help. The so 3 min read How to make a Inline Button using jQuery Mobile ? jQuery Mobile is a web based technology used to make responsive content that can be accessed on all smartphones, tablets and desktops. In this article, we will be making an Inline Button using jQuery Mobile. Approach: First, add jQuery Mobile scripts needed for your project. <link rel="stylesheet 1 min read How to Replace the Entire HTML Node using JavaScript? To replace an entire HTML node using JavaScript, you can use methods that allow you to remove an existing node and insert a new one in its place. Approach: Using replace() method Take the new document as a form of string(eg.. Str = '< html > < /html > '). Use .replace() method on the HTM 1 min read How to remove all CSS classes using jQuery ? In this article, we will remove all CSS classes for an element using jQuery. To remove all CSS classes of an element, we use removeClass() method. The removeClass() method is used to remove one or more class names from the selected element. Syntax: $(selector).removeClass(class_name, function(index, 2 min read How to remove specific div element by using JavaScript? Removing a specific `<div>` element with JavaScript is crucial for dynamic web content management. Whether updating information, responding to user actions, or optimizing performance by cleaning the DOM, efficient DOM manipulation is essential. JavaScript offers diverse methods such as `remove 3 min read Like