js 光标事件聚焦后,input文本框怎么自动弹出键盘1111111
<input type="text" name="fname" autofocus>
可以使用 focus() 方法使得 input 元素聚焦并弹出键盘。
html
<input id="myInput" type="text">
js
const input = document.getElementById("myInput");
input.addEventListener("focus", () => {
input.focus(); // 聚焦 input 元素
});
当 focus 事件被触发时,会调用回调函数将光标聚焦到 input 元素上,弹出键盘。
有用记得给个关注!
不知道你这个问题是否已经解决, 如果还没有解决的话:1. 显示密文
2. 只能输入数字
3. 调用数字键盘
1.密文:type = "password" / type="tel"
2.限制数字:用正则
3.调用数字键盘:type="tel" style="-webkit-text-security:disc"
<input type="tel" pattern="[0-9]*" style="-webkit-text-security:disc" onkeyup="value=value.replace(/[^\d]/g,'')" v-model="pwdID" placeholder="输入密码">