form表單中有個focus()方法可以直接鎖定input焦點,代碼如下:
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
</style>
</head>
<body>
<input type="text" id='input'>
</body>
<script>
document.getElementById("input").focus();
</script>
</html>