HTML button标签的 autofocus 属性

返回到:HTML button标签

本节课,我们学习HTML button标签的 autofocus 属性。

autofocus 属性是一个 boolean(布尔) 属性。

autofocus 属性规定当页面加载时按钮应当自动地获得焦点。

HTML 4.01 与 HTML5之间的差异

autofocus 属性是 HTML5 <button> 标签的新属性。

HTML 与 XHTML之间的差异

在 XHTML 中, 不允许属性简写,autofocus 属性必须定义为 <button autofocus=”autofocus”>。

语法

<button type="button" autofocus>

浏览器支持

Internet Explorer 10, Firefox, Chrome, 和 Safari 支持autofocus 属性。

注意: Internet Explorer 9 以及更早IE版本不支持 autofocus 属性。

实例

按钮使用 autofocus 属性:

<!DOCTYPE html>
<html>
<head> 
<meta charset="utf-8"> 
<title>Web176教程(web176.com)</title> 
</head>
<body>

<button type="button" autofocus >

返回到:HTML button标签

terry

这个人很懒,什么都没有留下~

Share
Published by
terry

Recent Posts

自定义指令:聊聊vue中的自定义指令应用法则

今天我们来聊聊vue中的自定义…

2 小时 ago

聊聊Vue中@click.stop和@click.prevent

一起来学下聊聊Vue中@cli…

7 天 ago

Nginx 基本操作:启动、停止、重启命令。

我们来学习Nginx基础操作:…

1 周 ago

Vue3:手动清理keep-alive组件缓存的方法

Vue3中手动清理keep-a…

2 周 ago

聊聊React和Vue组件更新的实现及区别

React 和 Vue 都是当…

3 周 ago