Tuesday, July 14, 2015

Using Jquery for a fixed footer


Following example shows the use of jquery to keep the footer at the bottom:


<script type="text/javascript">
$(document).ready(function(){

resizeContainer();

$(window).load(function() {
try {
resizeContainer();
}catch(err) {
return false;
}
});

});

function resizeContainer() {

x = $('.pageContainer').height() + 30; // 30 gives space between div and footer
y = $(window).height();

if (x + 30 <= y){
   $('.footer').css('position', 'fixed');
 
}else{
   $('.footer').css('position', 'relative');  
}
}
</script>

No comments:

Post a Comment