title: how to select element by class name in typescript?
body: <p>I am trying to design responsive menu bar that collapses in small screens, however, I am using typescript. is there any clue what equivalent to this code in typescript</p>
  
  <pre><code>function myFunction() {
  document.getElementsByClassName("topnav")[0].classList.toggle("responsive");}
  </code></pre>
  
  <p>I changed to this code in typescript but it never works </p>
  
  <pre><code>myFunction(): void {
  (&lt;HTMLScriptElement[]&gt;&lt;any&gt;document.getElementsByClassName("topnav"))[0].classList.toggle("responsive");
  }
  </code></pre>