Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

javascript change element class

//Overwrite all classes
element.className = "class";

//Add class
element.classList.add("class");
Comment

javascript change class name

function switchMode(){
    
    // Body switching
    if(document.getElementById("page-body").className == "page-body-day"){
        document.getElementById("page-body").className = "page-body-night";
    }else{
        document.getElementById("page-body").className = "page-body-day";
    }

    // Heading switching
    if(document.getElementById("main-heading").className == "main-heading-day"){
        document.getElementById("main-heading").className = "main-heading-night";
    }else{
        document.getElementById("main-heading").className = "main-heading-day";
    }

}
Comment

PREVIOUS NEXT
Code Example
Javascript :: make country flags in js 
Javascript :: how to stop type text texbox in javascript 
Javascript :: convert camelCase letter to Sentence case 
Javascript :: react-native date time picker 
Javascript :: iterate through object javascript 
Javascript :: jquery change the label of a value in select 
Javascript :: addeventlistener javascript 
Javascript :: each jquery 
Javascript :: how to use platform.select 
Javascript :: mongoose in node.js 
Javascript :: How to block ctrl+shift+j using javascript 
Javascript :: then js 
Javascript :: how to find the particular key and value in json in javascript 
Javascript :: react tooltip on disabled button 
Javascript :: vue 3 create component 
Javascript :: Find a character between space with Regex in js 
Javascript :: moment set time 
Javascript :: jspdf create table 
Javascript :: usememo react 
Javascript :: sequelize bulk update 
Javascript :: js blur element 
Javascript :: mongodb find array which does not contain object 
Javascript :: standalone apk build expo 
Javascript :: jquery get position of element 
Javascript :: javscript match word in string 
Javascript :: async function syntax in javascript 
Javascript :: mongoose-encryption 
Javascript :: trigger jquery 
Javascript :: delete element javascript 
Javascript :: sort by date javascript 
ADD CONTENT
Topic
Content
Source link
Name
9+5 =