Remove specific class from group of elements without jquery

后端 未结 3 2057
独厮守ぢ
独厮守ぢ 2020-12-22 12:57

I have multiple span elements, I try to remove the class activeLang. How can I do this?

3条回答
  •  执念已碎
    2020-12-22 13:52

    Remove . from the classname

    el.classList.remove("activeLang");
    

    window.onload = function() {
    
      var x = document.getElementsByClassName("activeLang");
      console.log(x[0]); //will print the object
      [].forEach.call(x, function(el) {
        el.classList.remove("activeLang");
      });
      console.log(x[0]); //will no longer print the object
    };
    ... ... ...

提交回复
热议问题