JQuery mCustomScrollbar autoScrollOnFocus

我有与reCaptcha的联系表单并使用jQuery mCustomScrollbar插件.

问题:当我点击/关注reCaptcha字段时,页面自动滚动到div的顶部.

Demo on Jsffidle,Code on Jsfiddle

注意:如果mscrollbar没有在jsfiddle上工作,那就是从malihu网站调用js和css的问题.

$(".scroller-back").mCustomScrollbar({
   advanced:{
     updateOnContentResize: true
   }           
});

使用autoScrollOnFocus:false

Auto-scrolling on elements that have focus (e.g. scrollbar
automatically scrolls-to form textfields when the TAB key is pressed),
values: true,false.

$(".scroller-back").mCustomScrollbar({
   advanced:{
     autoScrollOnFocus: false,updateOnContentResize: true
   }           
});

它适用于所有领域焦点不自动滚动,如何在不使用autoScrollOnFocus的情况下修复此问题:false?

解决方法

解决

我使用jQuery focus()和mCustomScrollbar scrollTo

$("#recaptcha_response_field").focus(function() {
  $(".scroller-back").mCustomScrollbar("scrollTo",this);
});

Code on Jsffidle

所以,当焦点(使用点击)recaptcha字段自动滚动到自己.但是当我使用tab键时它不起作用.我试着提醒

$('#recaptcha_response_field').focus(function() {
  alert('Handler for .focus() called.');
});

选项卡和单击时它的工作,我不知道jQuery focus()不使用scrollTo self

目前:

我正在使用带有目标ID提交按钮的scrollTo.

var a=Recaptcha.$("recaptcha_response_field");

$(a).focus(function() {
  $(".scroller-back").mCustomScrollbar("scrollTo","#submit_button");
});

Code on Jsffidle

相关文章

页面搜索关键词突出 // 页面搜索关键词突出 $(function () {...
jQuery实时显示日期、时间 html: <span id=&quot...
jQuery 添加水印 <script src="../../../.....
中文:Sys.WebForms.PageRequestManagerParserErrorExceptio...
1. 用Response.Write方法 代码如下: Response.Write(&q...
Jquery实现按钮点击遮罩加载,处理完后恢复 思路: 1.点击按...