Selecting text on focus using jQuery not working in iPhone iPad Browsers
html, jquery, jquery-mobile, mobile-website
Solution
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>
Problem
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