html焦点是什么意思

来自:互联网
时间:2022-06-18
阅读:

html焦点是什么意思

焦点在HTML和JS中是指光标。

焦点在JS和HTML里是在页面上屏幕中闪动的小竖线,鼠标点击就可获得光标,Tab键可按照设置的Tabindex来进行切换焦点。

autofocus 属性规定当页面加载时 input 元素应该自动获得焦点。

如果使用该属性,则 input 元素会获得焦点。

autofocus 属性是 HTML5 中的新属性。

autofocus 属性是一个布尔属性。

autofocus 属性规定当页面加载时 <input> 元素应该自动获得焦点。

语法如下:

<input autofocus>

或者

<input autofocus="autofocus">

示例如下:

<form action="demo_form.asp">
  First name: <input type="text" name="fname" autofocus><br>
  Last name: <input type="text" name="lname"><br>
  <input type="submit">
</form>

输出结果:

html焦点是什么意思

一旦刷新页面就会获得焦点

返回顶部
顶部