zoukankan      html  css  js  c++  java
  • JS 点击input文本框,文字消失

    http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>建站学JS点击输入框,框内文字消失实例www.jzxue.com</title>
    <script type="text/javascript">
    //得到焦点时触发事件
    function OnFocusFun(element,elementvalue)
    {
    if(element.value==elementvalue)
    {
    element.value="";
    element.style.color="#000";
    }
    }
    //离开输入框时触发事件
    function OnBlurFun(element,elementvalue)
    {
    if(element.value==""||element.value.replace(/\s/g,"")=="")
    {
    element.value=elementvalue;
    element.style.color="#999";
    }
    }
    </script>
    </head>
    <body>
    <div>欢迎学习建站学点击<strong>输入框</strong>框内文字消失实例</div>
    <div>
    <span>账号:</span>
    <input type="text" value="请输入用户名" id="UserId" onfocus="OnFocusFun(this,'请输入用户名')" style="color:#999"  onblur="OnBlurFun(this,'请输入用户名')"/>
    </div>
    <div>
    <span>密码:</span>
    <input type="text" value="请输入密码" id="Password" onfocus="OnFocusFun(this,'请输入密码')" onblur="OnBlurFun(this,'请输入密码')" style="color:#999" />
    </div>
    </body>
    </html>

    经验可以积累,但梦想永远不能磨灭
  • 相关阅读:
    纸牌游戏----小猫钓鱼
    数据结构-----栈
    浅谈队列
    排序算法实例
    排序算法之------快速排序
    排序算法之----冒泡排序
    Visual Studio-基本使用
    C++-GUID from string
    OS-Windows CMD生成文件夹目录结构
    OS-Windows10 DownLoad
  • 原文地址:https://www.cnblogs.com/lancee/p/2235867.html
Copyright © 2011-2022 走看看