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 trialhoward lawler
10,579 Pointscan'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
4 Answers
akak
29,445 Pointshey,
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();
Shawn Parrotte
6,689 PointsHey 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.
howard lawler
10,579 Pointsno, I just skipped over it
Chris Jackson
30,535 PointsDid you link to the jQuery library first?
Oğulcan Girginc
24,848 PointsIt 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!
Maybe there is a bug or something...
Faddah Wolf
12,811 Pointsthis 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.
Chris Jackson
30,535 PointsChris Jackson
30,535 PointsShouldn't it work with or without a dot, as a class or element?