我有以下代码在HTML网页中显示文本框.
<input type="text" id="userid" name="userid" value="Please enter the user ID" />
Run Code Online (Sandbox Code Playgroud)
页面显示时,文本中包含请输入用户ID消息.但是,我发现用户需要单击3次才能选择所有文本(在这种情况下,请输入用户ID).
只需点击一下即可选择整个文本吗?
编辑:
对不起,我忘了说:我必须使用输入 type="text"
我们的应用程序在输入字段上使用selectionStart来确定当用户按下箭头键时是否自动将用户移动到下一个/上一个字段(即,当选择位于文本末尾并且用户按下右箭头时我们移动到下一个字段,否则)
Chrome现在阻止在type ="number"的地方使用selectionStart.它现在抛出异常:
Failed to read the 'selectionStart' property from 'HTMLInputElement': The input element's type ('number') does not support selection.
Run Code Online (Sandbox Code Playgroud)
见如下:
https://codereview.chromium.org/100433008/#ps60001
http://www.whatwg.org/specs/web-apps/current-work/multipage/the-input-element.html#do-not-apply
有没有办法在type ="number"的输入字段中确定插入符的位置?
我需要本页底部的"确定"按钮,以便在打开时保持在键盘上方.它适用于Android,您可以在左侧的屏幕截图中看到,但不能在IOS中看到(右侧的屏幕截图).
你能帮我解决这个问题吗?
此外,你可以看到"选择焦点"指令在iOS中不起作用......键盘应该是iOS上的数字键盘(手机键盘)......而事实并非如此.
然后3个问题;)
这是一个视频:https: //youtu.be/_bOWGMGesgk
这是代码:
<div class="wrapperFlex withNextButton">
<div class="itemTitle">
<div class="text">
{{'paramQuestions.weight' | translate }}
</div>
</div>
<div id="weightdata" class="itemParameters weightdataclass row">
<input class="weightinput" type="number" name="userweight" ng-min="{{data.minWeight}}" ng-max="{{data.maxWeight}}" ng-model="data.realWeight" ng-change="updateViewGenVol(data.weightunit, data.userweight, data.BLfactorValue);saveUserWeight()" select-on-focus required></input>
<div class="weightunitradios">
<ion-checkbox class="checkboxes checkbox-blueboardline" ng-model="data.weightunit" ng-true-value="'kg'" ng-false-value="'lbs'" ng-change="saveWeightUnit(); changeMinMax(); convertWeightInput(); saveUserWeight();">kg</ion-checkbox>
<ion-checkbox class="checkboxes checkbox-blueboardline" ng-model="data.weightunit" ng-true-value="'lbs'" ng-false-value="'kg'" ng-change="saveWeightUnit(); changeMinMax(); convertWeightInput(); saveUserWeight();">lbs</ion-checkbox>
</div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
directives.js:
.directive('selectOnFocus', function ($timeout) {
return {
restrict: 'A',
link: function (scope, element, attrs) {
var …Run Code Online (Sandbox Code Playgroud)