当在没有javascript支持的情况下加载页面时,如何在文本框中放置光标(自动对焦)? [英] How to place the cursor (auto focus) in text box when a page gets loaded without javascript support?

查看:348
本文介绍了当在没有javascript支持的情况下加载页面时,如何在文本框中放置光标(自动对焦)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有一些文本字段的表单,并且当页面加载时,我想将光标(自动对焦)放置在表单的第一个文本字段上。

I have a form with some text fields,and I want to place the cursor (auto focus) on first text field of form when page gets loaded.

我不想使用javascript来做。

I want to do it without using javascript.

推荐答案



我们可以使用html5 自动对焦属性

例如:

Ya its possible to do without support of javascript..
We can use html5 auto focus attribute
For Example:

<input type="text" name="name" autofocus="autofocus" id="xax" />

如果在文本字段中使用它(autofocus =autofocus)意味着文本字段在页面get loaded。
有关详情:

http:// www.hscripts.com/tutorials/html5/autofocus-attribute.html

If use it (autofocus="autofocus") in text field means that text field get focused when page gets loaded.. For more details:
http://www.hscripts.com/tutorials/html5/autofocus-attribute.html

这篇关于当在没有javascript支持的情况下加载页面时,如何在文本框中放置光标(自动对焦)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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