I have javascript code to get the elements with class name and iterate over that remove the class from elements.
var elements = document.getElementsByClassName("test");
console.log("Length " + elements.length)
for (var i=0; i< elements.length;i++) {
console.log("---- "+i)
elements[i].setAttribute("class","");
}
and there are 3 span with the class name "test". HTML code is
<span class="test" id="test1">Test1 </span>
<span class="test" id="test2">Test2 </span>
<span class="test" id="test3">Test3 </span>
But I am getting only 2 class removed. The second span class still remains there.
The console output is
Length 3
---- 0
---- 1