版权声明:本文为博主原创文章,未经博主允许不得转载。 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 ">