×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Javascript
Posted by: Jing Tai Piao
Added: Aug 19, 2013 6:48 AM
Views: 62
Tags: no tags
  1. $('input, select, textarea').on('focus', function() {;
  2.         var that = $(this);
  3.         $('html, body').animate({
  4.             scrollTop: that.offset().top + that.height() / 2 - $(window).height() / 2
  5.         }, 2000);
  6.     });
  7.  
  8.     $('body,html').bind('scroll mousedown wheel DOMMouseScroll mousewheel keyup', function(e) {
  9.         if (e.which > 0 || e.type == "mousedown" || e.type == "mousewheel") {
  10.             $("html,body").stop();
  11.         }
  12.     });