I have an element that already has a class:
document.getElementById('some_id').className+=' someclassname'
OR:
document.getElementById('some_id').classList.add('someclassname')
First approach helped in adding the class when second approach didn't work.
Don't forget to keep a space in front of the ' someclassname'
in the first approach.
For removal you can use:
document.getElementById('some_id').classList.remove('someclassname')