JQuery input聚焦清空值,失焦赋值

 

$("input[type*=text]").each(function(){
  var oldValue=$(this).val();
  $(this).focus(function(){
    if($(this).val()==oldValue){
      $(this).val('');
    }
  })
  .blur(function(){
    if($(this).val()==""){
      $(this).val(oldValue)
    }else{
      oldValue = $(this).val();
    }
  })
});

 

posted @ 2022-07-04 01:03  悬剑丶  阅读(184)  评论(0编辑  收藏  举报