I have the following code which applies classes to the <nav>
element. The code works so no issues there.
$(document).ready(function() {
$(window).scroll(function() {
if ($(window).scrollTop() > 300) {
$('nav').addClass('stick');
$('nav').css('top','0');
}
if ($(window).scrollTop() < 300) {
$('nav').removeClass('stick');
$('nav').css('top', '0');
}
});
});
however I use two elements in my website so I only want the code to apply to this specific nav
html
<nav role="main-navigation"> ... </nav>
As well, I would also like the code to ONLY apply to this nav
element on screens >768px