输入文本框和文本区域自动清除

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了输入文本框和文本区域自动清除相关的知识,希望对你有一定的参考价值。

autoclear input text and text area
  1. $(function(){
  2. $('input:text, textarea').each(function(){
  3. var txtval = $(this).val();
  4. $(this).focus(function(){
  5. $(this).val('')
  6. });
  7. $(this).blur(function(){
  8. if($(this).val() == ""){
  9. $(this).val(txtval);
  10. }
  11. });
  12. });
  13. });

以上是关于输入文本框和文本区域自动清除的主要内容,如果未能解决你的问题,请参考以下文章