elements: $ ("button").click(function() { $ ("p").removeAttr("style"); }); Try it Yourself Definition and Usage The removeAttr () method removes one or more attributes from the selected elements. The .removeAttr () jQuery method removes an attribute from each element in the collection of matched elements.The method uses the JavaScript removeAttribute () function, but it is capable of being called directly on a jQuery object. It is easy to remove existing HTML elements. Asking for help, clarification, or responding to other answers. while (elements.len Use .remove () when you want to remove the element itself, as well as everything inside it. In addition to the elements themselves, all bound events and jQuery data associated with the elements are removed. To remove the elements without removing data and events, use .detach () instead. Consider the following HTML: The .Class Selector The jQuery .class attribute selector finds elements with a specific class. In addition to the elements themselves, all bound events and jQuery data associated with the Use the forEach () method to iterate over the collection. If you prefer not to use JQuery: function removeElementsByClass(className){ function. You can use the jQuery .appendTo () method to move an element into another element. The selected element will be taken out completely from its old location in the DOM and inserted at the end of the target container. Let's try out the following example: The returned jQuery object contains zero or more than one element Other related methods: parent () - returns the direct parent element of the selected element parentsUntil () - returns all ancestor elements between two given arguments Syntax Return the first ancestor of the selected element: $ ( selector ).closest ( filter) The easiest way we can use jQuery to hide an element by its class name is to use the jQuery hide()method. First you need to get the class of the button you clicked, then find the div with the same class and remove it. Later, just remove the button you clicked on: $("#your-button jquery body remove class remover clase jquery remove class element jquery add remove class clicked element jquery remove array of classes remove and add active You have to use the tag name, class name, or id of the elements to select.
Here's how you would do this for a removeAllByClassName = function (className) { function findToRemove () { var sets = document.getElementsByClassName (className); if (sets.length > 0) { sets [0].remove By using remove () property we can delete multiple divs with same class name for that we need to write the code like as shown below To remove several classes, separate the class names with space Note: If this parameter is empty, all class names will be removed: function(index,currentclass) Optional. Example-1: Using the jQuery remove () Method. Specify the selector to select the elements and remove the class names. The .css () jQuery method is used to set or return one or more style properties for the selected elements. To remove class jQuery syntax goes like this: $ ("selector").removeClass (class); The optional class defines the class to remove. jQuery remove () Method This method removes the selected elements, including all text and child nodes along with the data and events of the selected elements. One line document.querySelectorAll(".remove").forEach(el => el.remove()); className: It is the name of the class Removing all classes from an HTML element is done by leaving document.getElementsByClassName('my-class')[0].remove(); We can use the jQuery removeClass()method to remove all classes from an HTML element very easily. You can remove the ids and simply rely on the index of the elements: $('.tab li a').click( function(){ i = $(this).closest('li').index(); $('ul.lineup').eq(i).toggleClass('hideme'); Heres an example: