JQuery Detect the browser window top and change CSS on page
var t = $("#nav2").offset().top;
$(document).scroll(function() {
if ($(this).scrollTop() > t)
{
$('#nav2').css('position', 'fixed');
$('#nav2').css('top', '0');
}
else
{
$('#nav2').css('position', 'relative');
}
});
No comments:
Post a Comment