<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>js</title>
<style>
input{
margin: 10px;
100px;
height: 30px;
}
</style>
</head>
<body>
<input id="button1" type="button" value="button1">
<input id="button2" type="button" value="动态添加事件" onclick="addClick(button1)">
<input type="button" value="提交" onclick="check()">
<script>
function addClick(obj){
obj.onclick=function(){
alert('动态添加事件成功');
}
}
</script>
<script>
function check(){
if(window.document.readyState=='complete'){
alert("加载完毕,可以继续");
return true;
}else{
alert("正在处理,请等待!");
return false;
}
}
</script>
</body>
</html>