jQuery的重点在输入 [英] jquery focus on input

查看:149
本文介绍了jQuery的重点在输入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个主要的搜索字段总是可见的网站和一个登录表单(默认隐藏)只有当登录按钮被按下(这触发了jQuery切换功能)才可见。



我没有问题让主搜索字段有焦点,但是我希望登录表单中的第一个元素在可见的情况下具有焦点。



在HTML代码中,隐藏的div与登录表单放在主搜索字段div之前。



请帮忙! / p>

解决方案

您的切换代码:

 <$ c $ (); 
$(#login)。focus();
});


I got one main search field always visible at the site and a login form (by default hidden) only visible if the login button is pushed (this trigger a jQuery toggle function).

I have no problem getting the main search field to have focus, but I want the first element in the login form to have focus if visible.

In the HTML code, the the hidden div whith the login form is placed before the main search field div.

Please help!

解决方案

Your toggle code:

$("selector").toggle("fast", function() {
  $("#login").focus();
});

这篇关于jQuery的重点在输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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