IT
<!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>js自动判断标题应当填何值</title>
</head>

<body>
标题:<input id=
"title" name="title" value=""/>
<script>
function bindTitleEvent(){
     var TITLE =
"请填写相关标题内容";
var el = document.getElementById('title');
if (!el) return;
el.value = TITLE;
el.onfocus = function(){
if (el.value == TITLE) el.value = '';
}
el.onblur = function(){
if (el.value == '') el.value = TITLE;
}
}
bindTitleEvent();
</script>
</body>
</html>

查看效果
]查看效果[/url]/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>js自动判断标题应当填何值</title>
</head>

<body>
标题:<input id="title" name="title" value=""/>
<script>
function bindTitleEvent(){
     var TITLE = "请填写相关标题内容";
var el = document.getElementById('title');
if (!el) return;
el.value = TITLE;
el.onfocus = function(){
if (el.value == TITLE) el.value = '';
}
el.onblur = function(){
if (el.value == '') el.value = TITLE;
}
}
bindTitleEvent();
</script>
</body>
</html>
查看效果
posted on 2009-07-10 13:07  liufei  阅读(239)  评论(0编辑  收藏  举报