在调用函数时将焦点设置到文本框中 [英] Setting focus to a textbox when a function is called
本文介绍了在调用函数时将焦点设置到文本框中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我现在在aspx中有一个文本框:
< input type =textid =myTextboxvalue =/>
我想知道是否可以设置焦点(将光标放在该文本框中) JavaScript方法被调用。我希望它可以工作:
$ b $ pre $函数setFocus(){
document.getElementById( myTextbox)聚焦();
$ b $ p
$ b $ p
$ div $调用小写 .focus()
函数:
function setFocus(){
document.getElementById(myTextbox)。focus();
}
I currently have a textbox in my aspx:
<input type="text" id="myTextbox" value="" />
I was wondering if I could set the focus (put my cursor in that text box) every time my JavaScript method is called. I was hoping it would work along the lines of this:
function setFocus() {
document.getElementById("myTextbox").Focus();
}
Any suggestions?
解决方案
Invoke the lowercase .focus()
function:
function setFocus() {
document.getElementById("myTextbox").focus();
}
这篇关于在调用函数时将焦点设置到文本框中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文