<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<input id="kwords" type="text"><button>百度一下</button>
<script>
var input=document.getElementById("kwords");
//所有表单元素都有focus()函数,用于让当前元素自动获取焦点
input.focus();
</script>
</body>
</html>
(day05-01)自动获取焦点(类似百度)
最新推荐文章于 2024-10-28 18:25:21 发布