To certain elements that are accessed by their id and they are identified as List and wanted to delete the class if, and only if, it has the class ViewDelett0element
. The code below was an attempt, I would like to know if there is any property or other way to do it.
The class is ViewDelett0element and first I put it with this code:
for (var p = 0; p <= List.children.length -1; p++) {
List.children[p].addEventListener("click" , function() {
this.setAttribute("class", "ViewDelett0element");
});
}
And then I take it away with this other one
for (var k = 0; k <= List.children.length -1; k++){
List.children[k].addEventListener("click" , function(){
if(child.ClassName === ViewDelett0element){this.setAttribute("class", "");}
});
}
What happens is that when you give a first click you add a class to the element and in the second click you deselect or remove the class, I suppose that when you want to remove the class with the second click, the other function that adds the class and it seems like there is no change.