Cursor focus
html
html
<input type="text" id="studentId" maxlength="10" oninput="checkCode()" placeholder="卡號">
Javascript
Javascript
var inputElement = document.getElementById("studentId");
if (inputElement) {
inputElement.focus(); //游標移至input
}
先宣告變數物件inputElement,再利用focus方法將游標移至物件上。
先宣告變數物件inputElement,再利用focus方法將游標移至物件上。