jQuery如何隐藏搜索文本框文字
更新:HHH   时间:2023-1-7


这篇文章主要为大家展示了“jQuery如何隐藏搜索文本框文字”,内容简而易懂,条理清晰,希望能够帮助大家解决疑惑,下面让小编带领大家一起研究并学习一下“jQuery如何隐藏搜索文本框文字”这篇文章吧。

隐藏搜索文本框文字

Hide when clicked in the search field, the value.(example can be found below in the comment fields) 
 
$(document).ready(function() { 
$("input.text1").val("Enter your search text here"); 
   textFill($('input.text1')); 
}); 
 
    function textFill(input){ //input focus text function 
     var originalvalue = input.val(); 
     input.focus( function(){ 
          if( $.trim(input.val()) == originalvalue ){ input.val(''); } 
     }); 
     input.blur( function(){ 
          if( $.trim(input.val()) == '' ){ input.val(originalvalue); } 
     }); 
}

以上是“jQuery如何隐藏搜索文本框文字”这篇文章的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注天达云行业资讯频道!

返回web开发教程...