Chrome 的默认行为是隐藏键盘,当键盘打开/显示并且我单击屏幕的任何部分时。我想实现的是,如果我单击特定的 DOM 元素,它就不会隐藏。使用 JS 可以吗?
window.onclick = function(event) {
var sendMsgBtn = document.getElementById("send-msg-icon");
if (event.target == sendMsgBtn) {
//what to do here
}
}
最佳答案
如果您关注<input>
或<textarea>
元素(它可能是隐藏的)然后你点击它,键盘不会隐藏
window.onclick = function(event) {
var sendMsgBtn = document.getElementById("send-msg-icon");
if (event.target == sendMsgBtn) {
var input1 = document.getElementById("input1");
input1.focus();
input1.click();
}
}
关于javascript - 安卓浏览器: avoid keyboard to hide when icon is pressed,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60954379/