👋 Hello! I'm Alphonsio the robot. Ask me a question, I'll try to answer.

# How to add a class to a given element in JavaScript?

In JavaScript, the simplest way to add a class is to use the method ﻿.add() on the property ﻿.classList:

var element = document.getElementById('ID');
﻿element.classList.add('myClass');

More