function ys()
{
var chkother=document.getElementsByTagName("input");
for (var i=0;i<chkother.length;i++) { if( chkother[i].type =="text")
chkother[i].Attributes.Add("onfocus","alert('天下');")
}
}
<body onload ="ys()">chkother[i].Attributes.Add("onfocus","alert('天下');")
这句话问题在哪,为什么提示说Attributes为空或不是对象。我想知道是为什么不行?
chkother[i].setAttribute("onfocus",function (){alert('天下');})
chkother[i].setAttribute("onfocus","alert('天下');") 这个不行。。不知道为什么。。