- HTML Home
- HTML Roadmap
- HTML Introduction
- HTML History & Evolution
- HTML Editors
- HTML Basic Tags
- HTML Elements
- HTML Attributes
- HTML Headings
- HTML Paragraphs
- HTML Fonts
- HTML Blocks
- HTML Style Sheet
- HTML Formatting
- HTML Quotations
- HTML - Comments
- HTML - Colors
- HTML - Images
- HTML - Image Map
- HTML - Frames
- HTML - Iframes
- HTML - Phrase Elements
- HTML - Code Elements
- HTML - Meta Tags
- HTML - Classes
- HTML - IDs
- HTML - Backgrounds
- HTML Tables
- HTML - Tables
- HTML - Table Headers & Captions
- HTML - Table Styling
- HTML - Table Colgroup
- HTML - Nested Tables
- HTML Lists
- HTML - Lists
- HTML - Unordered Lists
- HTML - Ordered Lists
- HTML - Definition Lists
- HTML Links
- HTML - Text Links
- HTML - Image Links
- HTML - Email Links
- HTML Color Names & Values
- HTML - Color Names
- HTML - RGB & RGBA Colors
- HTML - HEX Colors
- HTML - HSL & HSLA Colors
- HTML - HSL Color Picker
- HTML Forms
- HTML - Forms
- HTML - Form Attributes
- HTML - Form Control
- HTML - Input Attributes
- HTML Media
- HTML - Video Element
- HTML - Audio Element
- HTML - Embed Multimedia
- HTML Header
- HTML - Head Element
- HTML - Adding Favicon
- HTML - Javascript
- HTML Layouts
- HTML - Layouts
- HTML - Layout Elements
- HTML - Layout using CSS
- HTML - Responsiveness
- HTML - Symbols
- HTML - Emojis
- HTML - Style Guide
- HTML Graphics
- HTML - SVG
- HTML - Canvas
- HTML APIs
- HTML - Geolocation API
- HTML - Drag & Drop API
- HTML - Web Workers API
- HTML - WebSocket
- HTML - Web Storage
- HTML - Server Sent Events
- HTML Miscellaneous
- HTML - Document Object Model (DOM)
- HTML - MathML
- HTML - Microdata
- HTML - IndexedDB
- HTML - Web Messaging
- HTML - Web CORS
- HTML - Web RTC
- HTML Demo
- HTML - Audio Player
- HTML - Video Player
- HTML - Web slide Desk
- HTML Tools
- HTML - Velocity Draw
- HTML - QR Code
- HTML - Modernizer
- HTML - Validation
- HTML - Color Picker
- HTML References
- HTML - Cheat Sheet
- HTML - Tags Reference
- HTML - Attributes Reference
- HTML - Events Reference
- HTML - Fonts Reference
- HTML - ASCII Codes
- ASCII Table Lookup
- HTML - Color Names
- HTML - Character Entities
- MIME Media Types
- HTML - URL Encoding
- Language ISO Codes
- HTML - Character Encodings
- HTML - Deprecated Tags
- HTML Resources
- HTML - Quick Guide
- HTML - Useful Resources
- HTML - Color Code Builder
- HTML - Online Editor
HTML - DOMTokenList remove() Method
HTML DOMTokenList remove() method is used to remove one or more tokens specified in parameter to the DOMTokenList.
Syntax
domtokenlist.remove(token);
Parameter
This method accepts a single parameter as listed below.
| Parameter | Description |
|---|---|
| token | It represents name of the token which you want to remove from DOMTokenList. |
Return Value
It does not return any value.
Examples of HTML DOMTokenList 'remove()' Method
The following examples illustrates implementation of DOMTokenList remove() method.
Removing a Class from Element
The following example illustrates remove a class to any element using remove() method. The removed class removes the background and text color of the element.
<!DOCTYPE html>
<html lang="en">
<head>
<title>HTML DOMTokenList remove() Method</title>
<style>
.color {
background-color: #04af2f;
color: white;
}
.font {
font-size: 40px;
}
</style>
</head>
<body>
<button onclick="fun()">Add</button>
<button onclick="remove()">Remove</button>
<p>Hii..</p>
<p id="remove">Welcome to Tutorials Point...</p>
<script>
function fun() {
let x = document.getElementById("remove").classList;
x.add("color", "font");
}
function remove() {
let x = document.getElementById("remove").classList;
x.remove("color");
}
</script>
</body>
</html>
Removing Multiple Classes from Element
In the following example, we have removed multiple classes from paragraph element.
<!DOCTYPE html>
<html lang="en">
<head>
<title>HTML DOMTokenList remove() Method</title>
<style>
.color {
background-color: #04af2f;
color: white;
}
.font {
font-size: 40px;
}
.align {
text-align: center;
}
</style>
</head>
<body>
<button onclick="fun()">Add</button>
<button onclick="remove()">Remove</button>
<p>Hii..</p>
<p id="remove">Welcome to Tutorials Point...</p>
<script>
function fun() {
let x = document.getElementById("remove").classList;
x.add("color", "font", "align");
}
function remove() {
let x = document.getElementById("remove").classList;
x.remove("color", "font");
}
</script>
</body>
</html>
Removing class using Conditional Statement
In the following example we have used conditional statement to remove class='align' if element has class='font'.
<!DOCTYPE html>
<html lang="en">
<head>
<title>HTML DOMTokenList remove() Method</title>
<style>
.color {
background-color: #04af2f;
color: white;
}
.font {
font-size: 40px;
}
.align {
text-align: center;
}
</style>
</head>
<body>
<button onclick="remove()">Remove</button>
<p>Hii..</p>
<p id="remove">Welcome to Tutorials Point...</p>
<script>
function remove() {
let x = document.getElementById("remove").classList;
x.add("color", "font", "align");
if (x.contains("font")) {
x.remove("align");
}
}
</script>
</body>
</html>
Supported Browsers
| Method | ![]() |
![]() |
![]() |
![]() |
![]() |
|---|---|---|---|---|---|
| remove() | Yes 8 | Yes 12 | Yes 3.6 | Yes 5.1 | Yes 12.1 |
html_dom.htm
Advertisements




