: :
复制代码代码如下:
<! doctype html public "-// w3c // dtd xhtml 1.0 transitional // en"
<html xmlns = "http://www.w3.org/1999/xhtml" xml: lang = "en" lang = "en">
<head>
<title> html 文本框提示效果 </itlem>
<type type = "text/css">
*{
الهامش: 0px ؛ الحشو: 0px ؛ حجم الخط: 12px ؛
}
مدخل{
العرض: 100px ؛ الارتفاع: 20 بكسل ؛ الحدود: 1 بكسل Solid #CCC ؛
}
</style>
</head>
<body>
<script language = "javaScript">
نصائح الدالة (id ، str) {
var l = document.getElementById (id) .OffSetLeft+120 ؛
var t = document.getElementById (id) .OffSetTop ؛
document.getElementById ("TIPS"). innerhtml = "提示 :"+str ؛
document.getElementById ("TIPS"). style.left = l+"px" ؛
document.getElementById ("TIPS"). style.top = t+"px" ؛
document.getElementById ("TIPS"). style.display = "" ؛
}
وظيفة Outtips () {
document.getElementById ("TIPS"). style.display = 'none' ؛
}
</script>
<div id = "tips" style = "الموضع: المطلق ؛ الحدود: 1px الصلبة #CCC ؛ الحشو: 0px 3px ؛ اللون:#f00 ؛ العرض: لا شيء ؛ الارتفاع: 20px ؛ خط الذروة: 20px ؛ الخلفية: #fcfcfc"> </div>
<br />
: : <input type = "text" id = "username" onfocus = "tips ('username' ، '姓名长度最多 16 个字符')" onblur = "outtips ()" />
<br />
: : <إدخال type = "password" id = "password" onfocus = "tips ('password' ، '密码长度必须在 3-18 位之间')" onblur = "outtips ()" />
</body>
</html>