Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript Using jQuery Plugins Add a Sticky Navigation Bar Adding Sticky Navigation

can't get sticky() to work

I can't get the sticky plugin to work. Have I missed something?

<script src="js/jquery-1.11.2.min.js"></script> <script src="js/animsition/jquery.animsition.min.js"></script> <script src="js/sticky/jquery.sticky.js"></script>
<script src="js/main.js"></script>

$('.header').sticky(); //from the main.js file

https://teamtreehouse.com/workspaces/9927742#

4 Answers

akak
akak
29,445 Points

hey,

The link to workspace doesn't work but if you have <header> in your HTML you should omit the dot since your not pointing to a class but to an element.

$('header').sticky();
Chris Jackson
Chris Jackson
30,535 Points

Shouldn't it work with or without a dot, as a class or element?

Shawn Parrotte
Shawn Parrotte
6,689 Points

Hey Howard, did you ever figure this out or know anything more about how to fix this? I have the same problem. I wrote everything the same, no sticky.

no, I just skipped over it

Chris Jackson
Chris Jackson
30,535 Points

Did you link to the jQuery library first?

Oğulcan Girginc
Oğulcan Girginc
24,848 Points

It didn't work for me too at first. After changing to $('header') it started worked but made me curious. Than, changed it back to $('.header') so I can test on other browsers and it started to work! :unamused:

Maybe there is a bug or something...

this could be a case of browser version compatibility with jQuery selecting classes ($('.header') for a class as opposed to $('header') for an overall header tag). on what browser, on what os platform and what version of the browser did this happen where changing it to 'header' then back to '.header' made it work?

best,

— faddah

 portland, oregon, u.s.a.