87,996
社区成员




<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title> new document </title>
<script type="text/javascript">
<!--
function addEventHandler(){
var oInput = document.getElementsByTagName("input");
for(var i = 0; i < oInput.length; i++ ){
if(oInput[i].type == "text"){
oInput[i].onblur = function(){
alert("Success Blur")
}
}
}
}
//-->
</script>
</head>
<body>
<input type="text" id="" /><br/>
<input type="text" id="" /><br/>
<input type="text" id="" /><br/>
<input type="text" id="" /><br/>
<input type="text" id="" /><br/>
<input type="button" value="添加事件" onclick="addEventHandler()" />
</body>
</html>
if(obj.attachEvent) {
obj.attachEvent("onchange",function() {//IE
otherfunction(params);//这里可以给其实方法传参,也可以直接调用其它方法
});
} else if(obj.addEventListener) {//FF
obj.addEventListener("change",function() {
otherfunction(params);
},false);
}
for(var i=0;i <input.length;i++){
input[i].onblur=某个函数名;
}