We are developing Web-App for Mobile browsers, we would like text of any input box to get selected whenever input-box get focus. Below answer fixes the issue for Desktop chrome/safari browser. Below solution works fine on Android browser, but not on iPhone/iPad browsers, any solution..
$("#souper_fancy").focus(function() { $(this).select() });
$("#souper_fancy").mouseup(function(e){
e.preventDefault();
});
Ref:-
Selecting text on focus using jQuery not working in Safari and Chrome
Answer found here don't know how to mark this question as duplicate. Programmatically selecting text in an input field on iOS devices (mobile Safari)
My fix look like this:-
<script type="text/javascript">
$('div,data-role=page').live('pageshow', function (event) {
jQuery.validator.unobtrusive.parse(".ui-page-active form");
$("input[type='text'], textarea, input[type='password'], input[type='number']").live('mouseup', function (e) { e.preventDefault(); });
$("input[type='text'], textarea, input[type='password'], input[type='number']").live('focus', function () {this.setSelectionRange(0, 9999); });
});
</script>
Maybe try this:
vmouseup
Normalized event for handling touchend or mouseup events
JS:
$("#souper_fancy").focus(function() {
$(this).select();
});
$("#souper_fancy").vmouseup(function(e){
e.preventDefault();
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With