通过javascript创建输入时选择iOS键盘
通过javascript创建输入时,mobile safari不会选择正确的键盘。对于通过javascript创建输入时选择iOS键盘,javascript,ios,input,keyboard,Javascript,Ios,Input,Keyboard,通过javascript创建输入时,mobile safari不会选择正确的键盘。对于第一个输入显示,但对于第二个输入仅显示 我怎样才能解决这个问题 让myInput=document.createElement('input'); myInput.id='秒'; myInput.type='number'; myInput.min='0'; myInput.step='any'; myInput.inputmode='decimal'; document.getElementById('he
第一个输入
显示,但对于第二个输入
仅显示
我怎样才能解决这个问题
让myInput=document.createElement('input');
myInput.id='秒';
myInput.type='number';
myInput.min='0';
myInput.step='any';
myInput.inputmode='decimal';
document.getElementById('here').appendChild(myInput)代码>
第一次输入:
第二次输入:
而不是使用:
myInput.inputmode = 'decimal';
使用以下命令:
myInput.setAttribute('inputmode','decimal');
或
说明:
通常,如果您使用javascript,html节点的“DOM属性”通常是以camelCase格式编写的!在HTML中,您将使用“alllowercase”版本。“别问为什么。”。但是,更建议在节点上使用setAttribute()
方法,因为无论您在'中编写什么,它都将在DOM元素属性中结束,而不是使用:
myInput.inputmode = 'decimal';
使用以下命令:
myInput.setAttribute('inputmode','decimal');
或
说明:
通常,如果您使用javascript,html节点的“DOM属性”通常是以camelCase格式编写的!在HTML中,您将使用“alllowercase”版本。“别问为什么。”。但是,更推荐在节点上使用setAttribute()
方法,因为无论您编写什么,它都将在DOM元素属性中结束