Ver Mensaje Individual
  #3 (permalink)  
Antiguo 11/04/2015, 21:56
Avatar de NueveReinas
NueveReinas
 
Fecha de Ingreso: septiembre-2013
Ubicación: No tan Buenos Aires
Mensajes: 1.101
Antigüedad: 10 años, 8 meses
Puntos: 145
Respuesta: llamar funcion al subir con el scroll

Quizá esto te sirva: http://jsfiddle.net/1ce711b0/

Código HTML:
Ver original
  1. <a href="#" class="arriba">Arriba</a>

Código CSS:
Ver original
  1. .arriba {
  2.     position:fixed;
  3.     background:red;
  4.     color:white;
  5.     opacity:0;
  6. }

Código Javascript:
Ver original
  1. // SCROLLTESTER START //
  2. $('<h1 id="st" style="position: fixed; right: 25px; bottom: 25px;"></h1>').insertAfter('body');
  3.  
  4. $(window).scroll(function () {
  5.   var st = $(window).scrollTop();
  6.   var scrollBottom = $(document).height() - $(window).height() - $(window).scrollTop();
  7.  
  8.   $('#st').replaceWith('<h1 id="st" style="position: fixed; right: 25px; bottom: 25px;">scrollTop: ' + st + '<br>scrollBottom: ' + scrollBottom + '</h1>');
  9. });
  10. // SCROLLTESTER END //
  11.  
  12. $(window).scroll(function(){
  13.    
  14.     var scrollBottom = $(document).height() - $(window).height() - $(window).scrollTop();
  15.    
  16. if (scrollBottom < 200) {
  17. $('.arriba').css("opacity","1");
  18. } else {
  19. $('.arriba').css("opacity","0");
  20. }
  21. });
  22. $('.arriba').click(function(){
  23. $("html, body").animate({ scrollTop: 0 }, 700);
  24. return false;
  25. });
__________________
¿Te sirvió la respuesta? Deja un +1