JavaScript与HTML之间的交互式通过事件实现的
onclick 点击事件
onfocus 获取焦点  
onblur 失去焦点
onmouseover  //鼠标移到某元素之上
onmouseout  //鼠标从某元素移开
onload页面加载时触发
onchange域的内容改变时发生
onsubmit//表单中的确认按钮被点击时发生
//有事件一定有对应一个处理结果,用函数表示
onresize//浏览器的尺寸发生改变
onscroll //窗口滚动
onchange事件支持的标签input,select,textarea
onclick onmouseover onmouseout
<style>/* div:hover{background: #333;} */</style></head><body><div id="test">hello world</div><script>/* 内容,样式,结构 */var test = document.getElementById("test");/*事件onclick 点击事件onmouseover 鼠标移到某元素之上onmouseout 鼠标从某元素移开*/test.onclick = function(){/* this在事件中指向正在执行事件的当前对象 */this.style.color = "red"/* innerHTML */this.innerHTML = "change"}/* 鼠标悬停的事件 */test.onmouseover = function(){this.style.backgroundColor = '#333'}/* 鼠标移除的事件 */test.onmouseout = function(){this.style.backgroundColor = '#fff'}</script>

onfocus onblur
<input type="text" id="input" value="good"><script>/* onfocus --获取焦点onblur --失去焦点*/var input = document.getElementById("input");input.onfocus = function(){this.style.backgroundColor = "red"}input.onblur = function(){this.style.background = "green"}</script>
onload onchange
<input type="text" id="input"><script>/*onload 等DOM树以及图片相关资源加载完毕,再执行函数中的代码*/window.onload = function(){var input = document.getElementById("input");input.onchange = function(event){console.log(this.value)}}</script>
onresize
<script>window.onresize = function(){/* window.innerWidth 获取窗口的width */console.log(window.innerWidth)}</script>

onscroll
<style>body{height: 2000px;}.nav{height: 60px;position: fixed;background: transparent;left:0;top:0;width:100%;}</style></head><body><div class="nav" id="nav">导航</div><script>/* onscroll 滚动事件 */var nav = document.getElementById("nav")window.onscroll = function(){/* 获取滚动条距离顶部的高度 */var scrollTop = document.documentElement.scrollTop;/* 当滚动条距离顶部的高度达到300时候完全显示 */var opacity = scrollTop/300;if(opacity>1){opacity = 1}nav.style.opacity = opacity;nav.style.backgroundColor = "red"}</script>


