Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var aChildren = $(".cd-faq-categories li a"); // find the a children of the list items
- var aArray = []; // create the empty aArray
- for (var i = 0; i < aChildren.length; i++) {
- var aChild = aChildren[i];
- var ahref = $(aChild).attr('href');
- aArray.push(ahref);
- }
- $(window).scroll(function () {
- var windowPos = $(window).scrollTop(); // get the offset of the window from the top of page
- var windowHeight = $(window).height(); // get the height of the window
- var docHeight = $(document).height();
- for (var i = 0; i < aArray.length; i++) {
- var theID = aArray[i];
- var divPos = $(theID).offset().top;
- // get the offset of the div from the top of page
- var divHeight = $(theID).height(); // get the height of the div in question
- if (windowPos >= divPos && windowPos < (divPos + divHeight)) {
- $("a[href='" + theID + "']").addClass("selected");
- } else {
- if ($("a[href='#cld9']"))
- {
- //...
- }
- else
- {
- $("a[href='" + theID + "']").removeClass("selected");
- }
- }
- }
- if (windowPos + windowHeight == docHeight) {
- alert("gfg");
- if (!$(".cd-faq-categories li a").hasClass("selected")) {
- var navActiveCurrent = $("li").attr("href");
- $("a[href='" + navActiveCurrent + "']").removeClass("selected");
- $("li a").addClass("selected");
- }
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement