== .removeClass ==

.removeClass()

Removes a class from an HTMLElement.
Usage:
[[mdn>Web/API/HTMLElement|HTMLElement]] = Element.removeClass(className)
Member of:
[[mdn>Web/API/HTMLElement|HTMLElement]]
Parameters:
className – the name of the class to remove as [[mdn>JavaScript/Reference/Global_Objects/String|String]] object, or as quoted string (required).
Returns:
The same HTMLElement that it was called on, thus allowing for command chaining.
Notes:
* If the class to be removed does not exist, this method does nothing. * This method is a simple wrapper for the [[mdn>Web/API/Element/classList|classList]]''.remove()'' method. The only difference is that this function returns the HTMLElement and thus allows chaining other functions for neater and/or more compact code.
===== Examples ===== Simple example: let foo = document.getElementById('foo'); foo.removeClass('bar'); Chaining allows for very compact code: document.getElementById('foo').removeClass('bar').attr('data-value', '123'); … and also allows to write very neat and readable code: document.getElementById('foo') .removeClass('bar') .attr('data-value', '123') ; ===== See also ===== * [[toolbox:classes:addclass:index|.addClass()]] * [[toolbox:classes:toggleclass:index|.toggleClass()]] * [[toolbox:classes:hasclass:index|.hasClass()]] ===== More information ===== * [[mdn>Web/API/HTMLElement|HTMLElement]] on MDN. * [[mdn>Web/API/Element/classList|classList]] on MDN.