如何在提交按钮单击后在jquery中将焦点设置在页面顶部。 [英] How to set focus on the top of page in jquery after submit button click.

查看:70
本文介绍了如何在提交按钮单击后在jquery中将焦点设置在页面顶部。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述







怎样才能将当前页面的焦点放到页面顶部,这样当使用jquery点击提交按钮时??

解决方案

像Aravindba所说,你不能专注于页面上的非输入项目。



但是,当用户点击提交按钮时,您可以通过滚动到页面顶部来设置设置视图。



 


' form')。on(' submit' function (){

' html,body')。animate({scrollTop:< span class =code-digit> 0 },' slow');
});





通过这种方式,您的页面轻轻地放到顶部o提交表单时的页面。



您可以通过将表单更改为更具体的代码特定表单的ID或名称,如


Hi,


How can iset the focus of the current page to the top of page so when click submit button using jquery??

解决方案

Like Aravindba said, you can't focus on non input items on your page.

However, you make "set view" by scrolling to the top of your page when the user clicks the submit button.


('form').on('submit', function() {


('html, body').animate({scrollTop:0}, 'slow'); });



This way, your page gently eases to the top of your page when the form is submitted.

You can make the code more specific by changing form to the id or name of a particular form like


这篇关于如何在提交按钮单击后在jquery中将焦点设置在页面顶部。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆