I didn't find the jQuery library in your html, you should put this snippet in the <head>
section of your html to make your jQuery code work:
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js" type="text/javascript"></script>
Question
I tryed to make my Navigation Sticky..but didn'T work.. here my JQuery code:
$(document).ready(function() {
var stickyNavTop = $('nav').offset().top;
var stickyNav = function(){
var scrollTop = $(window).scrollTop();
if (scrollTop > stickyNavTop) {
$('nav').addClass('sticky');
} else {
$('nav').removeClass('sticky');
}
};
stickyNav();
$(window).scroll(function() {
stickyNav();
});
});
and the used css-definitions:
.sticky {
position: fixed;
top: 0;
}
nav {
background: url('bilder/bg_nav.png') no-repeat;
width: 800px;
margin: 0 auto;
height: 40px;
}
you can see all at link
thank you for your help!
Solution
I didn't find the jQuery library in your html, you should put this snippet in the <head>
section of your html to make your jQuery code work:
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js" type="text/javascript"></script>
OTHER TIPS
your need to also include the jquery framework, ie http://code.jquery.com/jquery-2.0.3.js
I have an example here for you to follow.