How to add background color + border dynamically to keep together

Dear developers,

how can I add background color + border dynamically to keep together please? I prepared demo available at
https://jsfiddle.net/janzitniak/h6oac8pb/7/
please select any cell then click to to button Add background color and to the same cell use Add border button. It keeps only last formatting but I would like to keep both of them (background color and bordering as well).

Regards,
Jan

Hi @jan.zitniak

I think the better option is used classList - https://developer.mozilla.org/en-US/docs/Web/API/Element/classList

Then we don’t have a problem with an add another class to element (cell).

Here is an updated demo - https://jsfiddle.net/qtvduL21/

Hi @piotr.nowak,

thank you for your prompt answer, now it works as I expected. I would like to thank you for your professional approach.

Regards,
Jan