js点击事件 注册下一步实现代码
点击事件:
<body>
<input type="button" id="btn1"/>
<input type="button" value="按 钮" onclick="btn_click()" />
</body>
<script>
var btn1=document.getElementById("btn1");
btn1.onclick=function(){
alert("点击");
} //点击出发事件,第一种方式
function btn_click(){
alert("点击");
} //点击出发事件,第二种方式
</script>
<body>
<input type="text" onblur="alert('失去焦点')"/> //onblur 鼠标点击标签范围外的区域则进行提示
<select onchange="alert('改变')"> //onchange改变选项则进行提示
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
</select>
<input type="text" onkeyup="alert('按键抬起')" /> //onkeyup 输入停止则进行提示
<img src="../../img/qlrc-t/10292114_b20170717170239.gif"
onmouseover="alert('鼠标移上')" /> // onmouseover 鼠标移到制定区域提示
</body>
事件应用实例:同意 =》 下一步
<body>
<input type="checkbox" id="c1" />
<label for="c1">同意</label>
<input type="button" value="下一步" disabled="disabled" id="btn" />
</body>
<script>
var c1=document.getElementById('c1');
var btn=document.getElementById('btn');
c1.onchange=function(){
if(!c1.checked){
btn.setAttribute("disabled","disabled");
}else{
btn.removeAttribute("disabled");
}
}
</script>