[Solved] Uncaught reference error: jQuery is not defined (Sticky div)


First of all, you need to actually include jQuery. On JsFiddle, there is an option in the JavaScript section to add it. In an actual webpage you will need to add a link to either a local version, or hosted version of the library.

You can use this to reference it online

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>

Next, all of your jQuery selectors are incorrect. To select an element by id, you need to add a # at the beginning, like this

var stickyOffset = jQuery("#canbesticky").offset().top;

Lastly, you can use a nice little shorthand to save yourself some typing. jQuery can be replaced with $, like this

var stickyOffset = $("#canbesticky").offset().top;

solved Uncaught reference error: jQuery is not defined (Sticky div)