FastClick.prototype.focus = function(targetElement) {
var length;
if (deviceIsIOS && targetElement.setSelectionRange && targetElement.type.indexOf('date') !== 0 && targetElement.type !== 'time' && targetElement.type !== 'month' && targetElement.type !== 'email') {
// must targetElement.focus() first
length = targetElement.value.length;
targetElement.setSelectionRange(length, length);
} else {
targetElement.focus();
}
};
method setSelectionRange can set selection in a focused input element
and in this example (https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/setSelectionRange),
function SelectText () {
var input = document.getElementById("mytextbox");
input.focus();
input.setSelectionRange(2,5);
}
also input.focus() first
so, if you want use setSelectionRange, you must input.focus() first
in my code, click input can not focus, must rewrite FastClick.prototype.focus.
FastClick.prototype.focus = function(targetElement) { var length; if (deviceIsIOS && targetElement.setSelectionRange && targetElement.type.indexOf('date') !== 0 && targetElement.type !== 'time' && targetElement.type !== 'month' && targetElement.type !== 'email') { // must targetElement.focus() first length = targetElement.value.length; targetElement.setSelectionRange(length, length); } else { targetElement.focus(); } }; method setSelectionRange can set selection in a focused input element and in this example (https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/setSelectionRange),
function SelectText () { var input = document.getElementById("mytextbox"); input.focus(); input.setSelectionRange(2,5); }
also input.focus() first so, if you want use setSelectionRange, you must input.focus() first
in my code, click input can not focus, must rewrite FastClick.prototype.focus.
is it a bug in ios?