/*设置input 焦点*/
$(function () {
    //集体调用 
    $(".formTextBoxes input").each(function () {
        $(this).setDefauleValue();
    });
    //单个调用 
    $(".textkey").setDefauleValue();
})

//设置input,textarea默认值 .之前写法$.fn.seDefauleValue = function(){
$.fn.setDefauleValue = function () {
    var defauleValue = $(this).val();
    $(this).val(defauleValue).css("color", "#999");

    return this.each(function () {
        $(this).focus(function () {
            if ($(this).val() == defauleValue) {
                $(this).val("").css("color", "#000"); //输入值的颜色 
            }
        }).blur(function () {
            if ($(this).val() == "") {
                $(this).val(defauleValue).css("color", "#999"); //默认值的颜色 
            }
        });
    });
}

Html:

 <div class="formBoxes formTextBoxes clearfix">
            <input id="txtSearch" type="text" value='@ViewBag.SearchText'  class="searchMainBtn easyui-validatebox" />
            <div id="btnSearch" class="btnGo" >@ViewBag.Search</div>
        </div>

 

相关文章:

  • 2022-12-23
  • 2021-10-17
  • 2022-12-23
  • 2022-02-23
  • 2022-12-23
  • 2021-10-15
  • 2022-12-23
  • 2021-11-04
猜你喜欢
  • 2021-10-17
  • 2022-12-23
  • 2021-08-23
  • 2021-12-08
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案