[jQuery Code] Use the jQuery library to check the position at the bottom of the page and adjust page elements if necessary

Requirements:

withjQueryDetermine that when the footer section appears in the visual range, calculate the distance from the top of the footer section to the bottom of the window, and increase the distance by +60px to add the bottom attribute to. freecatalogs


Solution:

$(document).ready(function() {
  checkFooterPosition();
});

$(window).scroll(function() {
  checkFooterPosition();
});

function checkFooterPosition() {
  var windowBottom = $(window).scrollTop() + $(window).height();
  var footerTop = $('footer').offset().top;
  var A = $(document).width();
  if (A > 1280) {
  if (windowBottom >= footerTop) {
     var distance = windowBottom - footerTop + 60;
     $('.freecatalog').css('bottom', distance);
  } else {
     $('.freecatalog').css('bottom', '');
  }
}
}

This code uses the jQuery library to check the location of the bottom of the page to adjust page elements if necessary. Specifically, when the window is scrolling or the page is loaded, a function called "checkFooterPosition()" is called to check the position at the bottom of the page. If the browser width is greater than 1280 pixels, it checks to see if the bottom of the page has been reached. If you have reached the bottom of the page, an element called "freecatalog" is moved up 60 pixels to avoid overlapping with the footer. If you do not reach the bottom of the page, no adjustments are made.

Tag:jQuery
t like2

Link to this article:https://en.finchui.com/program/28.html

netizens commented

guess you like

hot commodity
popular articles
hot Tags
related tags
FinchUI Store Edition

Share

Copy Link
Working hours: 9:00-22:00
Saturday and Sunday: 14:00-22:00
wechat
Scan the code to add customer service WeChat