var chkother=document.getElementsByTagName("input"); //获取页面上input标签的集合
for (var i=0;i<chkother.length;i++) { //遍历input标签 if( chkother[i].type =="text") //判断是否是文本框
{
chkother[i].Attribute.Add("onfocus","c=ojbNode.style.background;ojbNode.style.background='#ECF9FC';")
chkother[i].Attribute.Add("onblur","ojbNode.style.background=c;")
}
}我是想在加载的时候给文本框控件添加焦点事件,可是弄的晕晕的后面这两个添加事件怎么提示对象为空呢,不明白,代码问题在哪里,有知道的朋友说下
解决方案 »
- 问一个比较简单的问题,为什么我写的onclick在页面载入完成前会自动触发?
- outerHTML应用
- 很奇怪的问题,这一句放在页面就有效,放在js文件就无效
- 问一个最简单那的问题(在线等)是关于JavaScript的
- 关于JS不能全部取消checkbox的问题
- 怎么用javascript实现自动注册。
- window.open("logout.aspx?id="+<%=SessionID%>)无响应,应该怎么改?
- 关于写好的一个搜索 出现的问题
- 如何实现输入“I am Tom”,输出“Tom am I”
- 求助:一个表单中有多个input,数量不确定,怎么验证不为空,一次性提交后,怎么获取到值?
- 用JS做这个flash的效果能行吗
- JS点击自动滚屏的问题
var chkother=document.getElementsByTagName("input");
for (var i=0;i<chkother.length;i++) { if( chkother[i].type =="text")
{
chkother[i].Attribute.Add("onfocus","c=chkother[i].style.background;chkother[i].style.background='#ECF9FC';")
chkother[i].Attribute.Add("onblur","chkother[i].style.background=c;")
}
}
}是这个,哪里有问题呢?
c=chkother[i].style.background;
chkother[i].style.background = '#ECF9FC';
};
var f2 = functon () {
chkother[i].style.background = c;
};
if(window.attachEvent)
{
chkother[i].attachEvent('onfoucs', f1);
chkother[i].attachEvent('onblur', f2);
}
else
{
chkother[i].addEventListener('foucs', f1);
chkother[i].addEventListener('blur', f2);
}