How to use a Navigation-Part in JQuery (ul.nav li a)?

How to use a Navigation-Part in JQuery (ul.nav li a)?

Hey guys!

I have a question about, how i can use a class for an jquery action.

Here my example:
  1. .balken {
  2.     height: 100px;
  3.     width: 100%;
  4.     background-color: white;
  5.     border-top: 5px solid lightskyblue;
  6.     display: flex;
  7. }
This is a bar at the top, in it is a picture and a navigation bar, you can see that they a in a flexbox.

  1. .sticky {
  2.     height: 50px;
  3.     position: fixed;
  4.     border-bottom: 2px solid red;
  5.     border-top: 0px;
  6. }
When you will scroll, the class sticky will be added to the .balken. This means the height will reduzed to 50px.

This is the script for it and it works!
  1. $(document).ready(function(){
  2.   $(window).scroll(function() {
  3.     if ($(document).scrollTop() > 50) {
  4.       $('.balken').addClass("sticky");
  5.     } else {
  6.       $('.balken').removeClass("sticky");
  7.     }
  8.   });
  9. });


Now i want to do this with the navigation bar, i want to change the padding:

  1. ul.nav li a {
  2.     display: inline-block;
  3.     color: black;
  4.     padding: 24px 26px;
  5.     text-decoration: none;
  6.     transition: 0.3s;
  7.     font-size: 30px;
  8.     text-align: center;
  9. }
and the sticky:
  1. .stickynav {
  2.     padding: 10px 14px;
  3. }

Now i tried to do this like this:
  1. $(document).ready(function(){
  2.   $(window).scroll(function() {
  3.     if ($(document).scrollTop() > 50) {
  4.       $('.balken').addClass("sticky");
  5.       $('ul.nav.li.a').addClass("stickynav");
  6.     } else {
  7.       $('.balken').removeClass("sticky");
  8.       $("ul.nav.li.a").removeClass("stickynav");
  9.     }
  10.   });
  11. });
But this isn't working. So my question is, how can i edit the ul.nav li a? Is this even possible and how?

I hope you can help me!

Best regards,
D4niel