manhuatoTop.1.0.js 764 B

1234567891011121314151617181920212223242526272829303132333435
  1. /***
  2. * 漫画Jquery时间插件
  3. * 编写时间:2012年7月17号
  4. * version:manhuatoTop.1.0.js
  5. ***/
  6. $(function() {
  7. $.fn.manhuatoTop = function(options) {
  8. var defaults = {
  9. showHeight : 150,
  10. speed : 1000
  11. };
  12. var options = $.extend(defaults,options);
  13. $("body").prepend("<div id='totop'><a></a></div>");
  14. var $toTop = $(this);
  15. var $top = $("#totop");
  16. var $ta = $("#totop a");
  17. $toTop.scroll(function(){
  18. var scrolltop=$(this).scrollTop();
  19. if(scrolltop>=options.showHeight){
  20. $top.show();
  21. }
  22. else{
  23. $top.hide();
  24. }
  25. });
  26. $ta.hover(function(){
  27. $(this).addClass("cur");
  28. },function(){
  29. $(this).removeClass("cur");
  30. });
  31. $top.click(function(){
  32. $("html,body").animate({scrollTop: 0}, options.speed);
  33. });
  34. }
  35. });