How to add class to a element depending on the class of another item?

For example, if the element with id wow-block-one's got class .this, then element with id list-block-one add class .active
https://jsfiddle.net/s7s22ebp/2/
July 8th 19 at 11:52
2 answers
July 8th 19 at 11:54
Solution
https://jsfiddle.net/s7s22ebp/3/
var list = document.querySelectorAll('[id^="list-block"]');

[].forEach.call(document.querySelectorAll('[id^="wow-block"]'), function(el, i){
 if (el.classList.contains('this')) {
list[i].classList.add('active');
}
});
It's cool, thanks. - Uriah commented on July 8th 19 at 11:57
July 8th 19 at 11:56
revove class -> remove class
add class -> add class

Find more questions by tags JavaScript