文本焦点小程序

来源:互联网 发布:linux 重启日志 编辑:程序博客网 时间:2024/06/06 13:55

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>文本框焦点问题</title>
</head>
<body>
<!--onBlur:当失去输入焦点后产生该事件
onFocus:当输入获得焦点后,产生该文件
Onchange:当文字值改变时,产生该事件
Onselect:当文字加亮后,产生该文件
-->
<script type="text/javascript">
document.write("<input type=\"text=\" value=\"请输入用户名\" " +
"onfocus=\"if (value=='请输入用户名'){value=''}\"" +
"onblur=\"if(value==''){value='请输入用户名'}\">");
/*特色按钮的使用*/
document.write("<input type=\"button\" name=\"Button1\" value=\"按钮1\" size=\"10px\" style=\"background-color: cornflowerblue\">");
/*鼠标离开时颜色变化*/
document.write("<input type=\"button\" value=\"按钮会变化颜色\" onmouseover=this.style.color=\"red\" onmouseout=this.style.color=\"blue\" >");
</script>

</body>
</html>

0 0