以编程方式在iOS设备上的输入字段中选择文本(移动Safari) [英] Programmatically selecting text in an input field on iOS devices (mobile Safari)

查看:123
本文介绍了以编程方式在iOS设备上的输入字段中选择文本(移动Safari)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您如何以编程方式选择iOS设备上的输入字段的文本iPhone,iPad上运行移动Safari?

How do you programmatically select the text of an input field on iOS devices, e.g. iPhone, iPad running mobile Safari?

正常情况下调用 .select() code>< input ... /> 元素,但这不适用于这些设备。

Normally it is sufficient to call the .select() function on the <input ... /> element, but this does not work on those devices. The cursor is simply left at the end of the existing entry with no selection made.

推荐答案

setSelectionRange(0, 9999);

https://developer.mozilla.org/en/DOM/Input.select

这篇关于以编程方式在iOS设备上的输入字段中选择文本(移动Safari)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆