jsfiddle: http://jsfiddle.net/MFUw3/5/
jQuery:
function showDiv() {
if ($(window).scrollTop() > 610) {
$(\".a\").css({\"position\": \"
Here's something that should suit your needs:
function showDiv() {
if ($(window).scrollTop() > 610 && $('.a').data('positioned') == 'false') {
$(".a").hide().css({"position": "fixed", "top": "10px"}).fadeIn().data('positioned', 'true');
} else if ($(window).scrollTop() <= 610 && $('.a').data('positioned') == 'true') {
$(".a").fadeOut(function() {
$(this).css({"position": "relative", "top": "0px"}).show();
}).data('positioned', 'false');
}
}
$(window).scroll(showDiv);
$('.a').data('positioned', 'false');
And the link to the working example: http://jsfiddle.net/MFUw3/10/
Edit: I have added the code improvements suggested by Sparky672 and the (initially omitted) fadeout.