zoukankan      html  css  js  c++  java
  • 【锋利的JQuery-学习笔记】输入框提示语-隐藏/显示

    html

                    <div class="search">
                        <input type="text" id="inputSearch" class="" value="请输入商品名称"/>
                    </div>

    css:

    #inputSearch {
        border: 1px solid #BABEBF;
        color: #999999;
        font-size: 14px;
        height: 17px;
        padding: 3px 6px 5px 6px;
        width: 200px;
    }

      #inputSearch.focus{
       border: 1px solid red;
    }

    js:

    $(function () {
        $("#inputSearch").focus(function () {
            $(this).addClass("focus");
            if ($(this).val() == this.defaultValue) {
                $(this).val("");
            }
        }).blur(function () {
            $(this).removeClass("focus");
            if ($(this).val() == "") {
                $(this).val(this.defaultValue);
            }
        }).keyup(function (e) {
            if (e.which == 13) {
                alert("提交后台搜索");
            }
        });
    });
  • 相关阅读:
    反射:框架设计的灵魂
    Junit测试
    XML笔记
    map 的用法
    opencv总结1
    光源
    镜面反射
    openGL纹理对象
    GPU入门
    动态规划1
  • 原文地址:https://www.cnblogs.com/easy5weikai/p/3702735.html
Copyright © 2011-2022 走看看