title: How to solve Uncaught TypeError: Cannot read properties of undefined (reading 'toggle')
body: <p>I would like to add a &quot;-js-expanded&quot; class to this element if someone hover over a tag. how can I do this?</p>
  <pre class="lang-html prettyprint-override"><code>&lt;a href=&quot;&quot; target=&quot;_self&quot; class=&quot;sticky-cta&quot; onmouseover=&quot;myFunction()&quot; &gt;
    &lt;span class=&quot;sticky-label&quot;&gt;GET STARTED&lt;/span&gt;
    &lt;i class=&quot;icon-features-productivity&quot;&gt;&lt;/i&gt;
  &lt;/a&gt;
  </code></pre>
  <pre class="lang-js prettyprint-override"><code>  function myFunction () {
        this.classList.toggle(&quot;-js-expanded&quot;);
    }
  </code></pre>
  <pre class="lang-css prettyprint-override"><code>  .-js-expanded {
    color: red;
    }
  </code></pre>