Javascript 触摸外部输入时,保持手机键盘打开

Javascript 触摸外部输入时,保持手机键盘打开,javascript,Javascript,我有几张照片,当用户触摸每张照片时,我会显示一个不同的input字段来编辑文本 轻触第一个输入,键盘打开并编辑。 现在,如果用户想在键盘打开时显示下一张照片,但键盘将关闭 如何保持键盘打开,让用户触摸照片并专注于下一个输入 尝试此方法但未成功: document.getElementById(id).classList.remove("hidden"); document.getElementById(id).focus(); 您可以对所有图像使用单个输入元素 只需将inputs的值存

我有几张照片,当用户触摸每张照片时,我会显示一个不同的
input
字段来编辑文本

轻触第一个
输入
,键盘打开并编辑。 现在,如果用户想在键盘打开时显示下一张照片,但键盘将关闭

如何保持键盘打开,让用户触摸照片并专注于下一个
输入

尝试此方法但未成功:

  document.getElementById(id).classList.remove("hidden");
  document.getElementById(id).focus();

您可以对所有图像使用单个
输入
元素

只需将
input
s的值存储在一个数组中,该数组最初设置为空白字符串。然后根据选择的图像,将
input
的值设置为数组中相应的值

// No. of images
let n = 5; // Take 5 for example
let values= []; // will contain values like { imageId: string, value: string }

// Initialize the values here
    ...
// End of initialization

// Current selected image is
let selectedImage = 'someId'; 

// Let all the images have a class `.image`
let images = document.querySelectorAll('.image');
for(let i=0; i<images.length; i++) {
    images[i].onclick = function () {
          let textBox = document.querySelector('#input');
          // Store the value in the array before
          values = values.map(function(m) {
                if (m.imageId === selectedImage) {
                    return {
                        imageId: m.imageId,
                        value: textBox.value
                    };
                }
                return m;
          });
          textBox.value = values.filter(function(m) {
             return m.imageId === this.id;
          })[0].value;
    };
}
//图像数量
设n=5;//以5为例
让值=[];//将包含类似{imageId:string,value:string}的值
//在这里初始化值
...
//初始化结束
//当前选定的图像为
让selectedImage='someId';
//让所有图像都有一个类“.image”`
让images=document.queryselectoral('.image');

对于(设i=0;它不工作。一旦你触摸一个新的照片键盘,它就会关闭。