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("提交后台搜索");
        }
    });
});

 

 

 

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-02-16
  • 2021-10-20
  • 2021-06-18
  • 2021-04-21
  • 2021-06-07
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-11-19
  • 2022-12-23
  • 2021-12-04
  • 2021-11-18
  • 2022-12-23
相关资源
相似解决方案