Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

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";
    }

}
Source by stackabuse.com #
 
PREVIOUS NEXT
Tagged: #javascript #change #class
ADD COMMENT
Topic
Name
6+9 =