如何在BootStrap的第一个输入栏中设置焦点? [英] How to set focus on first field of input in BootStrap?

查看:104
本文介绍了如何在BootStrap的第一个输入栏中设置焦点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<强>可能重复:结果,


  • Possible Duplicate:
    How to set the focus to the first input element in an HTML form independent from the id?

    我在ASP.NET MVC4中使用BootStrap。有一个登录表单,但我无法专注于第一个输入字段。

    I'm using BootStrap with ASP.NET MVC4. There is one login form but I'm unable to set focus on first input field.

    如何将焦点设置在第一个输入字段?是否有使用将焦点设置任何引导类?

    How to set focus on first field of input? Is there any BootStrap class that uses to set focus?

    推荐答案

    有没有特定的自举类或函数,这是否*,但HTML5提供自动对焦属性输入字段。

    There isn't a Bootstrap-specific class or function that does this*, but HTML5 provides the autofocus attribute for input fields.

    此属性目前享有广泛的浏览器支持

    * - 由于您使用Bootsrap,并引导由jQuery的动力,你可以 垫片 旧的浏览器,否则不支持自动对焦:

    *-Since you are using Bootsrap, and Bootstrap is powered by jQuery, you could "shim" older browsers that otherwise don't support autofocus:

    $('[autofocus]:first').focus();
    

    这篇关于如何在BootStrap的第一个输入栏中设置焦点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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