如何判断哪一个文本框被选中

rion10 2003-01-21 04:19:36
1:<input type="text" name="Text1">
<input type="text" name="Text2">
<input type="text" name="Text3">
。。。
如何得知form中哪一个文本框被选中,最好不要用循环的方法,

2:if(obj.type == "text") //判断是否文本框
if(obj.type == "checkbox") //判断是否复选框
如何判断是否select?



...全文
240 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
希默软件 2003-01-21
  • 打赏
  • 举报
回复
在文本框onfocus时调用FocusText,在FocusText()中如何判断哪个文本框被选中?

event.srcElement

如何判断是否select?

event.srcElement.tagName="SELECT"
rion10 2003-01-21
  • 打赏
  • 举报
回复
for(;;)
{
if(obj.type == "text")
{
oneElt.attachEvent("onfocus", FocusText);
}
}

在文本框onfocus时调用FocusText,在FocusText()中如何判断哪个文本框被选中?

meizz 2003-01-21
  • 打赏
  • 举报
回复
<body onselectstart="meizz = document.activeElement.name">
这个变量 meizz 就是你选择了的那个文本框的 name

obj.type == "text"
obj.type == "radio"
obj.tagName == "INPUT"
obj.tagName == "SELECT"
rion10 2003-01-21
  • 打赏
  • 举报
回复
1。wealth不对
2。我就是不想在每个text加onfocus事件阿,最后加
for(;;)
{
oneElt.attachEvent("onfocus", FocusText);
}
wangyime 2003-01-21
  • 打赏
  • 举报
回复
<input type=text onfocus=alert('选中')>
给每个<input>加onfocus事件
wealth 2003-01-21
  • 打赏
  • 举报
回复
if(obj.type == "select")

87,996

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧