onfocus:获取焦点 onblur:失去焦点
eg:获取焦点时背景为红色,失去焦点时背景为黄色
代码:
<body><input id="app" type="text" ><script>var app=document.getElementById("app");app.onfocus =function(){this.style.backgroundColor="red"}app.onblur =function(){this.style.backgroundColor="yellow"}</script></body>

