Try using click
instead of focus
. It seems to work for both mouse and key events (at least on Chrome/Mac):
jQuery < version 1.7:
$("input[type="text"]").click(function () {
$(this).select();
});
jQuery version 1.7+:
$("input[type="text"]").on("click", function () {
$(this).select();
});