我有一个输入字段(使用redux形式):
<input
{...input}
autoFocus
onFocus={(e)=> {
var val = e.target.value;
e.target.value = '';
e.target.value = val;
}}
className={'hinput'}
value={input.value}/>
输入为焦点时,它将从您单击的位置开始输入(从值的右侧或左侧)。当输入集中时,如何强制用户从头开始输入?
错误的行为:
I tried to use the function onFocus
and try to e.target.value=''
to reset the value so it will go to the beginning, but it does not work. Thanks in advance
I think the function you need to move the selection point is HTMLInputElement.setSelectionRange().