/**
* Detect whether the element has scrollbar
* @param {HTMLElement} elem
* @return {Boolean} true: has scrollbar; false: hasn't
*/
function isScroll(elem) {
return elem.scrollHeight > elem.clientHeight;
}
/**
* Set the position of footer
*/
function setFooterPosition() {
var pageContainer = $('footer').parents('.page-container') || $('body');
$('footer').removeClass('fixed-bottom');
if (!isScroll(pageContainer[0])) {
$('footer').addClass('fixed-bottom');
}
}
如果你确定一定要
的话:
PS. 额外赠送根据页面内容是否超出一屏来判断是否要让
footer固定在页面底部: