<!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>