Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/466.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
通过javascript创建输入时选择iOS键盘_Javascript_Ios_Input_Keyboard - Fatal编程技术网

通过javascript创建输入时选择iOS键盘

通过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

通过javascript创建输入时,mobile safari不会选择正确的键盘。对于
第一个输入
显示,但对于
第二个输入
仅显示

我怎样才能解决这个问题

让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元素属性中结束