I’m trying to make a sticky navigation behavior but the jquery script seems not to be working or loading.
This is my html:
<html>
<head>
<title>Title</title>
<link rel="stylesheet" type="text/css" href="css/style.css" />
</head>
<body>
<div id="logo-menu">
<div id="main-menuid">
<ul>
<li><a href="#home">Home</a></li>
<li><a href="#about">About</a></li>
<li><a href="#menu">Menu</a></li>
<li><a href="#contact">Contact</a></li>
</ul>
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.js" type="text/javascript"></script>
<script src="js/source.js" type="text/javascript"></script>
</body>
</html>
I have some more markups to make my page scroll down to test the sticky nav.
This is the source.js:
(function() {
// STICKY NAV
console.log('hi')
var $ nav = $ ('#logo-menu'),
navTop = $ nav.offset().top,
$ navClone = $ nav.clone(true)
.hide()
.addClass('sticky')
.insertBefore($ nav);
$ (window).scroll(function() {
if ($ (this).scrollTop() > navTop) {
$ navClone.show();
} else {
$ navClone.hide();
}
});
Even the console.log(‘hi’) doesnt show up on firebug console. Any idea? or did i miss something? TIA!