<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script type="text/javascript" language="javascript">
//得到焦点时触发事件
function onFocusFun(element,elementValue){
if(element.value==elementValue){
element.style.color = "";
element.value = "";
}
}
//离开输入框时触发事件
function onblurFun(element,elementValue){
if(element.value==''){
element.style.color = "#CCCCCC";
element.value = elementValue;
}
}
</script>
</head>
<body>
<input name="textfield" type="text" value="默认值" style="color: #CCCCCC" onFocus="onFocusFun(this,'默认值')" onblur="onblurFun(this,'默认值')"/>
</font>
</body>
</html>
posted on 2008-09-16 11:54
梓枫 阅读(1492)
评论(0) 编辑 收藏 所属分类:
html