How in JS to list of classes?

There is an element, for example:
<span class="one two">content</span>

Want by clicking on it to get the string one two i.e. the list of styles? I want to style list and add to it another, for example to make one two three.

Separate to is not a problem, for example
var need = document.getElementById(id).style.background;

but that's not it
June 14th 19 at 20:44
2 answers
June 14th 19 at 20:46
Solution
https://developer.mozilla.org/ru/docs/Web/API/Elem...

here, as to how to add how to remove
June 14th 19 at 20:48
Solution
Let's say we have an element
<div class="a b" id="ab"></div>
In order to access its classes we use
ab.classList;
Will return an array
(2) ["a", "b", value: "a b"]
To add a new class use the command
ab.classList.add('c');
As a result, we have the following element
<div class="a b" id="ab"></div>
All information about such nuances can be found on Learn JavaScript

Find more questions by tags JavaScript