“Javascript Change Name” Respostas de código

JS Set Class

var element = document.getElementById('element');
element.classList.add('class-1');
element.classList.add('class-2', 'class-3');
element.classList.remove('class-3');
just-saved-you-a-stackoverflow-visit

Javascript Change Element Class

document.getElementById("myElementID").classList.add('myClassName');
document.getElementById("myElementID").classList.remove('myClassName');
Grepper

Javascript Change Element Class

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

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

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

}
vexeval

Respostas semelhantes a “Javascript Change Name”

Perguntas semelhantes a “Javascript Change Name”

Mais respostas relacionadas para “Javascript Change Name” em JavaScript

Procure respostas de código populares por idioma

Procurar outros idiomas de código