I tried to trigger a transition with javascript, but is not working,

So, i’m very new to html, css and javascript, and i trying to trigger a transition with javascript, but it’s not working, "menu-icon" it’s a span tag with a litle image that is inside another div, that’s also inside the header, here’s the code (i’m using microsoft edge).

<script>
  const openMenu = document.querySelector('.menu-icon');
  openMenu.addEventListener('click', () => {
    openMenu.style.transform.scaleX = 100%;
  });
</script>

The edge DevTools said that it was a syntax error (a bracket on the line 5, column 1), but when I deleted it, it said that it was the parenthese next to it, I deleted it, and now it says there’s not an end for the input.

>Solution :

Please use this code instead:

<script>
  const openMenu = document.querySelector('.menu-icon');
  openMenu.addEventListener('click', () => {
    openMenu.style.transform = "scaleX(100%)";
  })
</script>

Leave a Reply