className only changing every other class

后端 未结 15 2201
陌清茗
陌清茗 2020-12-01 23:41

I\'m performing a small text with JavaScript with the getElementsByClassName() and I am getting some unwanted results. I would like the script to change each CS

15条回答
  •  一向
    一向 (楼主)
    2020-12-01 23:51

    This error is because you need to do

    blockSet[0].className = 'block-selected'

    You don't to write blockSet[1] , blockSet[2] ...

    You can do:

    for (var s=0;s

提交回复
热议问题