原生js的触焦onfcus和失焦onblur
var inp1=document.getElementById('inp1'); inp1.onfocus=function(){ if(inp1.value=="请输入..."){ inp1.value=""; inp1.style.color="white"; } } inp1.onblur=function(){ if(inp1.value==""){ inp1.value="请输入..."; inp1.style.color="#ccc"; } }