HTML DOM TokenList.replace() Method Last Updated : 12 Jul, 2022 Comments Improve Suggest changes Like Article Like Report The replace() method in HTML DOM is used to replace or change an old token with a new one in a DOM TokenList Object. Syntax: domtokenlist.replace(old, new) Parameter Values: It contains two values: old: It is a required parameter, that specifies the name of the token that would be replaced. new: It is a required parameter, that specifies the name of the new token that replaces with. Example: Below HTML code demonstrate the use of replace() method in HTML DOM. HTML <!DOCTYPE html> <html> <head> <style> .geek { background-color: coral; font-size: 50px; } .hello { background-color: green; font-size: 30px; font-style: italic; } </style> </head> <body> <h2 id="gfg" class="geek"> GeeksforGeeks </h2> <h2> HTML DOM TokenList replace() Method </h2> <button onclick="myGeek()">Submit</button> <script> function myGeek() { var elem = document.getElementById("gfg"); // Replacing class from div element // with a new class elem.classList.replace("geek", "hello"); } </script> </body> </html> Output: Supported Browsers: Google Chrome 61 and aboveMozilla Firefox 49 and aboveEdge 17 and aboveSafari 10.1 and aboveOpera 48 and aboveInternet Explorer not supported Create Quiz Comment M manaschhabra2 Follow 0 Improve M manaschhabra2 Follow 0 Improve Article Tags : HTML HTML-DOM HTML-Methods Explore HTML BasicsHTML Introduction4 min readHTML Editors4 min readHTML Basics7 min readStructure & ElementsHTML Elements4 min readHTML Attributes7 min readHTML Headings3 min readHTML Paragraphs3 min readHTML Text Formatting4 min readHTML Block and Inline Elements3 min readHTML Charsets4 min readListsHTML Lists3 min readHTML Ordered Lists5 min readHTML Unordered Lists4 min readHTML Description Lists3 min readVisuals & MediaHTML Colors11 min readHTML Links Hyperlinks2 min readHTML Images7 min readHTML Favicon4 min readHTML Video4 min readLayouts & DesignsHTML Tables9 min readHTML Iframes4 min readHTML Layout4 min readHTML File Paths3 min readProjects & Advanced TopicsHTML Forms4 min readHTML5 Semantics5 min readHTML URL Encoding4 min readHTML Responsive Web Design11 min readTop 10 Projects For Beginners To Practice HTML and CSS Skills8 min readTutorial ReferencesHTML Tags - A to Z List5 min readHTML Attributes Complete Reference8 min readHTML Global Attributes5 min readHTML5 Complete Reference8 min readHTML5 MathML Complete Reference3 min readHTML DOM Complete Reference15+ min readHTML DOM Audio/Video Complete Reference2 min readSVG Element Complete Reference5 min readSVG Attribute Complete Reference8 min readSVG Property Complete Reference7 min readHTML Canvas Complete Reference4 min read Like