Jquery arrow keys between divs not working

I have been trying to make a sample site that scrolls between full page divs using the arrow keys. However, my code has been getting stuck, with my variable for the div to scroll to coming up as undefined every time.

Here is my code: https://codepen.io/Umma2/pen/mdJJxNe?

Hello emma.

You have a few issues in your Pen.

  1. For CodePens, you should place your CDN links/scripts in the settings section of the HTML.
  2. Classes are separated by spaces, not commas:
    <div class="active other-css"></div>
    What you have done is set the class of your element to active,
    But in your JS, you are searching for the class active
  3. You should define the class in the CSS:
    .active { color: green; }
    That is just what I did.

Hope this helps

1 Like