将光标位置聚焦在第四个或其他文本框中 [英] Focusing Cursor position in fourth or other Textbox

查看:85
本文介绍了将光标位置聚焦在第四个或其他文本框中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我试图将第四个文本框控件集中在javascript中,但是当页面加载时我无法将光标放在第四个文本框上光标移动到第四个文本框位置,但在完全加载文本框后,光标无法聚焦该文本框,

任何人都可以帮助我......这个。我写的代码如

  document  .getElementById( '  custpage_scanitem')。focus(); 



但我没有得到输出..

解决方案

为什么不尝试加载onLoad()页面事件,以便在页面加载后它立即聚焦。现在的问题可能是你试图在你的元素创建之前调用焦点方法因此它没有被聚焦。

  function  myFocus(){
document .getElementById(' < span class =code-string> custpage_scanitem')。focus();
}





用html写下面的代码



 <   body     onload   =  myFocus >  <   / body  >  


Hi All ,

I am trying to focus the fourth text box control in javascript but i am not able to get the cursor on fourth textbox,when page loading the cursor goes to the fourth text box position but after fully loading the textbox the cursor not able to focus the that text box,
can any one help me..this. i have write the code like

document.getElementById('custpage_scanitem').focus();


But i didn't get the output..

解决方案

Why dont you try to load it onLoad() page event,so that it will focus as soon as your page is loaded. The problem now might be that you are trying to call focus method on your element even before it is created hence it not being focused.

function myFocus(){
 document.getElementById('custpage_scanitem').focus();
}



Write the below code in html

<body onload="myFocus"></body>


这篇关于将光标位置聚焦在第四个或其他文本框中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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