I'm currently working on a list of items (ul, li) that have a class applied to them which adds a left border and bold highlight when clicked.
My goal is to reset the style of the previously clicked item back to its original state when a new item is clicked, and then apply the new style to the currently active item.
What's puzzling is that even though the DOM inspection shows that the previous items still have the altered class, the console output indicates otherwise.
function myFunctionTest(id_word) {
var items = document.getElementsByClassName("process-itemz");
for (var i = items.length - 1; i >= 0; --i) {
items[i].classList.remove("test123");
}
var element = document.getElementById(id_word);
element.classList.add("test123");
}
For a live demonstration, check out this fiddle: https://jsfiddle.net/y5kwmu6j/