How to target .style attribut with .querySelectorAll selector?

前端 未结 2 1021
一整个雨季
一整个雨季 2021-01-23 16:14

I have selected a specific class via .querySelectorAll:

var hit3 = document.querySelectorAll(\".lattern.hit-3 .circle\");

I am now

2条回答
  •  一生所求
    2021-01-23 17:11

    querySelectorAll return a node list so you should specify the index of element you want to change :

    hit3[0].style.visibility = "visible";
    

    If you want to change the css of all the elements returned you should loop through them, see Johny's answer.

    Hope this helps.

提交回复
热议问题