How to change the style of elements with same class name

后端 未结 3 1772
挽巷
挽巷 2020-12-18 15:43

Using javascript, I want to change the style of class .s into

.s {
  display: block;
}

Why this cannot work:

         


        
3条回答
  •  佛祖请我去吃肉
    2020-12-18 16:14

    var sCls = document.getElementsByClassName('s');
    for(var i in sCls) {
        sCls[i].style.display='block';
    }
    

    this may work!

提交回复
热议问题