skip to Main Content

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.

2

Answers


  1. that’s great code! This is a simple mistype – have a look at using a code validator next time, I find it’s very helpful with something like this too. Here’s one I have used before: https://codebeautify.org/jsvalidate#

    Login or Signup to reply.
  2. Please use this code instead:

    <script>
      const openMenu = document.querySelector('.menu-icon');
      openMenu.addEventListener('click', () => {
        openMenu.style.transform = "scaleX(100%)";
      })
    </script>
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search