Currently working on designing a personal ASP.NET Web page, I have encountered an issue with making a sticky div using jQuery. Despite all my other jQuery functions functioning properly, the sticky div seems to be causing trouble.
stickydiv.js
$(document).ready(function () {
var s = $("#stick_body");
var pos = s.position();
$(window).scroll(function () {
var windowpos = $(window).scrollTop();
s.html("Distance from top:" + pos.top + "<br />Scroll position: " + windowpos);
if (windowpos >= pos.top) {
s.addClass("stick");
} else {
s.removeClass("stick");
}
});
});
I made sure to reference this file in my content page (hobbies.aspx), and also included the main jQuery file (jquery-latest.min.js) in the master page's section. However, upon running the project, an error was thrown:
Unhandled exception at line 1, column 2 in http...stickydiv.js 0x800a138f - JScript Runtime Error: Object Expected.
Even after trying to reference the stickydiv.js file in the master page, the error persisted.