JS——提取行间事件 结构与行为分离

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_37049781/article/details/85000473

某一按钮按下时触发一个事件

<script type="text/javascript">
	function hello(){
		alert('hello world !')
}
</script>

<input type="button" name="" value="打个招呼" onclick="hello()">
<script type="text/javascript">
	winodw.onload = function(){
		var btn = document.getElementById('btn')
		btn.onclick = function (){
			alert('hello world')
	}
}
</script>

<input type="button" name="" value="打个招呼" id="btn                      ">

猜你喜欢

转载自blog.csdn.net/qq_37049781/article/details/85000473
今日推荐