yinpeng186

文本框如下:

 

 <input type="text" value="请输入关键字" id="search" />

 

JS代码如下:

 

   $("#search").focus(function cls() {
        //捕获触发事件的对象,并设置为以下语句的默认对象 
        with (event.srcElement)
        //如果当前值为默认值,则清空 
            if (value == defaultValue) value = ""
    });
    $("#search").blur(function res() {
        //捕获触发事件的对象,并设置为以下语句的默认对象 
        with (event.srcElement)
        //如果当前值为空,则重置为默认值 
            if (value == "") value = defaultValue
    });

 

分类:

技术点:

相关文章:

  • 2017-12-12
  • 2021-12-19
  • 2021-12-19
  • 2021-12-19
  • 2021-09-05
  • 2021-12-19
  • 2021-12-19
  • 2021-12-19
猜你喜欢
  • 2021-12-19
  • 2021-11-30
  • 2021-12-19
  • 2021-12-19
  • 2021-12-19
  • 2021-12-19
  • 2021-12-09
相关资源
相似解决方案