聚焦并选择表单输入

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了聚焦并选择表单输入相关的知识,希望对你有一定的参考价值。

For forms with a default value onload you don't want your users to have to select the value, delete it and then insert their own input.

This function focuses on a selected input, then it selects the default text so the user can easily type their own value.
  1. /** @id codeFocus
  2. * @classDescription Focuses on the selected input and selects the value text.
  3. */
  4. var postcodeFocus = {
  5. grab:function(){
  6. if(!document.getElementById){return;};
  7. if(!document.getElementById('selected')){return;};
  8. var theInput = document.getElementById('selected');
  9. theInput.focus();
  10. theInput.select();
  11. }
  12. }

以上是关于聚焦并选择表单输入的主要内容,如果未能解决你的问题,请参考以下文章

聚焦并选择输入移动

JavaScript 聚焦并选择表格输入

带有名称的无效表单控件...不可聚焦

聚焦时输入隐藏在键盘下(Phonegap android)

name='' 的无效表单控件不可聚焦。没有任何必需或隐藏的输入

忍者表单文本字段在移动设备上弹出