I have a script that basically is to remove the class “no-js” from the body and add the class “js”, but the script is not working. What did I do wrong?
<!doctype html> <html lang="pt-br"> <head> <title> Infusion </title> </head> <body class="no-js"> </body> </html> function removeClassBody(){ var body = document.querySelector('body'); body.classList.remove('no-js'); body.classList.add('js'); } ()removeClassBody;
Advertisement
Answer
You have to call the function like thie removeClassBody();
function removeClassBody(){ var body = document.querySelector('body'); body.classList.remove('no-js'); body.classList.add('js'); } removeClassBody();
<!doctype html> <html lang="pt-br"> <head> <title> Infusion </title> </head> <body class="no-js"> </body> </html>