How to getElementByClass instead of GetElementById with JavaScript?

前端 未结 7 689
孤街浪徒
孤街浪徒 2020-11-22 09:33

I\'m trying to toggle the visibility of certain DIV elements on a website depending on the class of each DIV. I\'m using a basic JavaScript snippet to toggle them. The probl

7条回答
  •  长情又很酷
    2020-11-22 09:42

    Append IDs at the class declaration

    .aclass, #hashone, #hashtwo{ ...codes... }
    document.getElementById( "hashone" ).style.visibility = "hidden";
    

提交回复
热议问题