adaptar codigo em java scrips

I’m not a programmer, I understand very little code, but I need to create a link in one that hides and shows several objects with the same class (doubt it)… Could someone help me, please?
I found this code fragment that apparently works, but my limitations do not allow me to adapt it to be used with {class}, not {id} as it appears there


function myFunction() {
  var x = document.getElementById("SoftExpert");
  if (x.style.display === "none") {
    x.style.display = "block";
  } else {
    x.style.display = "none";
  }
}