Back to top mal configuré
Bonjour à tous !
Je dispose de ce JS, mais celui-ci s'applique mal, j'explique:
J'ai fais un back to top, mais celui-ci réapparaît puis redisparaît après avoir cliquer dessus.
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
| $(document).ready(function(){
$('body').prepend('<a href="#top" class="top_link" title="Revenir en haut de page">Haut de page</a>');
$('.top_link').css({
'position' : 'fixed',
'width' : '70px',
'right' : '5px',
'bottom' : '5px',
'display' : 'none',
'padding' : '5px',
'background' : '#fff',
'background-color' : 'black',
'-moz-border-radius' : '30px',
'-webkit-border-radius' : '30px',
'border-radius' : '30px',
'z-index' : '2000',
'text-decoration' : 'none',
'color' : '#0090FF',
'font-family' : 'arial',
'font-size' : '14px',
'border' : '2px solid #0090FF',
'text-align' : 'center',
});
$(window).scroll(function(){
posScroll = $(document).scrollTop();
if(posScroll >=150)
$('.top_link').fadeIn(600);
else
$('.top_link').fadeOut(600);
});
$('.top_link').click(function(){
$('html,body').animate({scrollTop: 0}, 1000);
});
}); |
Merci de votre réponse.