zoukankan      html  css  js  c++  java
  • 鼠标点到文本框时的提示信息

    今天看到一小功能,还不错,做个记录,以后也许用得上:
    <!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" xml:lang="en" lang="en">

    <head>
      
    <title></title>
      
    <style type="text/css">
      *
    {
      margin
    :0px;padding:0px;font-size:12px;
      
    }
        input
    {
          width
    :100px;height:20px;border:1px solid #ccc;
        
    }

      
    </style>
    </head>

    <body>
    <script language="javascript">
    function tips(id,str){
    var l=document.getElementById(id).offsetLeft;
    alert(document.getElementById(id).offsetTop); alert(document.getElementById(id).clientHeight);
    var t=document.getElementById(id).offsetTop+document.getElementById(id).clientHeight+5;
    document.getElementById(
    "tips").innerHTML="提示:"+str;
    document.getElementById(
    "tips").style.left=l+"px";
    document.getElementById(
    "tips").style.top=t+"px";
    document.getElementById(
    "tips").style.display="";
    }
    function outtips(){
        document.getElementById(
    "tips").style.display='none';
    }
    </script>
    <div id="tips" style="position:absolute;border:1px solid #ccc;padding:0px 3px;color:#f00;display:none;height:20px;line-height:20px;background:#fcfcfc"></div>
    <br />
    姓名:
    <input type="text" id="username" onfocus="tips('username','姓名长度最多16个字符')" onblur="outtips()" />
    <br />
    密码:
    <input type="password" id="password" onfocus="tips('password','密码长度必须在3-18位之间')" onblur="outtips()" />
    </body>
    </html>
  • 相关阅读:
    【php数组函数序列】之array_values()
    Mysql数据库编码问题3(修改数据库,表,字段编码为utf8)
    framework fckedit / KingEditor
    Linux + JDK/TOMCAT/Dia(Planner)/eclipse
    proxyServer squid / varnish / apache traffic server / ATS
    framework SiteMesh
    Linux + BusyBox
    对链表的插入操作
    链表原理
    链表的删除操作
  • 原文地址:https://www.cnblogs.com/linyechengwei/p/1597825.html
Copyright © 2011-2022 走看看