<!doctype html>
<html lang="en">
 <head>
  <meta charset="UTF-8">
  <meta name="Generator" content="EditPlus®">
  <meta name="Author" content="zzp">
  <meta name="Keywords" content="">
  <meta name="Description" content="">
  <title>Document</title>
  <style type="text/css">   
    input:focus,textarea:focus{
       border:1px solid #f00;
       background:#fcc;
    
    }
    .focus{
       border:1px solid #f00;
        background:#fcc;
    }

   </style>
    <script type="text/javascript" src="js/jquery-1.6.4.min.js" ></script>
    <script type="text/javascript">
       var temp;
     $(function(){
           $(":input").focus(function(){   //获得焦点
                 alert(this.id);  
                 alert("获得焦点时的值是:"+$(this).val());  
                 temp=$.trim($(this).val());
                 alert(temp);
                $(this).addClass("focus");   //添加样式

           }).blur(function(){ //失去焦点
               $(this).removeClass("focus"); //移除样式
               alert("失去焦点时的值是:"+$(this).val());  
               var lastValue = $.trim($(this).val());  

               if(temp != lastValue && null !=lastValue && "" !=lastValue)
               {
                   alert("值改变了!");
               }
              
               else{
                  alert("值没有变!");
               }
               /**     */    

           });
    
     });
    
    </script>


 </head>
 <body>
    <form action="#" method="post" >
         </div>
      
      
      </fieldset>
    
    
    </form>
 </body>
</html>

相关文章:

  • 2021-11-11
  • 2021-12-09
  • 2021-12-09
猜你喜欢
  • 2022-03-03
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-09
相关资源
相似解决方案